mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-16 16:02:36 +00:00
fix: mark batch as failed when event send fails in first-time handler
The return value of _send_events_to_backend() was discarded in _initialize_backend_and_send_events, so _finalize_backend_batch was called unconditionally with the full event count even when the send returned 500. This finalized the batch as "completed" on the server while it received 0 events, producing an empty trace URL. Now check the return status and call mark_trace_batch_as_failed on 500, matching the behavior of the regular finalize_batch path.
This commit is contained in:
@@ -111,7 +111,13 @@ class FirstTimeTraceHandler:
|
||||
|
||||
events_count = len(self.batch_manager.event_buffer)
|
||||
if self.batch_manager.event_buffer:
|
||||
self.batch_manager._send_events_to_backend()
|
||||
send_status = self.batch_manager._send_events_to_backend()
|
||||
if send_status == 500 and self.batch_manager.trace_batch_id:
|
||||
self.batch_manager.plus_api.mark_trace_batch_as_failed(
|
||||
self.batch_manager.trace_batch_id,
|
||||
"Error sending events to backend",
|
||||
)
|
||||
return
|
||||
|
||||
self.batch_manager._finalize_backend_batch(events_count)
|
||||
self.ephemeral_url = self.batch_manager.ephemeral_trace_url
|
||||
|
||||
Reference in New Issue
Block a user