Skip to content

Commit ec0481f

Browse files
MichaelGHSegclaude
andcommitted
Wire on_error callback in e2e-cli for failure reporting
Add on_error handler to capture delivery failures from the SDK. Reports success=false with the first error message when any batch fails (non-retryable error or retries exhausted). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 98df1bc commit ec0481f

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

e2e-cli/src/cli.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ def run(input_json: str, debug: bool):
7070
"""Run the E2E CLI with the given input configuration."""
7171
logger = setup_logging(debug)
7272
output = {"success": False, "sentBatches": 0, "error": None}
73+
delivery_errors = []
74+
75+
def on_error(error, batch):
76+
delivery_errors.append(str(error))
7377

7478
try:
7579
data = json.loads(input_json)
@@ -96,6 +100,7 @@ def run(input_json: str, debug: bool):
96100
write_key=write_key,
97101
host=api_host,
98102
debug=debug,
103+
on_error=on_error,
99104
upload_size=flush_at,
100105
upload_interval=flush_interval,
101106
max_retries=max_retries,
@@ -120,10 +125,12 @@ def run(input_json: str, debug: bool):
120125
client.flush()
121126
client.join()
122127

123-
output["success"] = True
124-
# Note: We don't have easy access to batch count from the SDK internals
125-
# This could be enhanced if needed
126-
output["sentBatches"] = 1 # Placeholder
128+
if delivery_errors:
129+
output["success"] = False
130+
output["error"] = delivery_errors[0]
131+
else:
132+
output["success"] = True
133+
output["sentBatches"] = 1
127134

128135
except json.JSONDecodeError as e:
129136
output["error"] = f"Invalid JSON input: {e}"

0 commit comments

Comments
 (0)