Skip to content

fix: do not retry event batches rejected with a 4xx status - #129

Open
pcbeingused33 wants to merge 2 commits into
DevCycleHQ:mainfrom
pcbeingused33:fix/events-4xx-not-retryable
Open

pcbeingused33 wants to merge 2 commits into
DevCycleHQ:mainfrom
pcbeingused33:fix/events-4xx-not-retryable

Conversation

@pcbeingused33

@pcbeingused33 pcbeingused33 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

The event queue re-enqueues batches rejected with HTTP 400 or 413 because it handles those responses the same way as retryable API errors.

The event client carries the HTTP status on the existing APIClientError. The queue keeps the existing failure callback and drops batches rejected with 400 (Bad Request) or 413 (Content Too Large). Retryable failures such as 429 and 5xx still follow the queue's retry path. The existing authorization and endpoint error handling still applies.

The HTTP-mocked tests cover the exception type and status, the drop decision for 400 and 413, and the retry decision for 408, 422, 429 and 500. The full Python 3.12 unit suite passed (154 passed, one skipped), as did Black, Ruff and mypy.

This change was prepared with AI assistance.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pcbeingused33
pcbeingused33 requested a review from a team as a code owner November 28, 2026 12:47
@JamieSinn

Copy link
Copy Markdown
Member

Hi,

Can you elaborate why this specifically needs a dedicated error handling event?

As is, I don't see a reason to add/break the current flow of events.

@pcbeingused33

Copy link
Copy Markdown
Contributor Author

Thanks, Jamie, fair point: a dedicated exception wasn't needed, so it's gone. The reason for the change: today every APIClientError from the events API ends in on_event_payload_failure(payload_id, True), so a batch the API rejects with 400 or 413 is re-queued and sent again on every flush, and it can never succeed as-is. The update keeps the existing flow and exception: APIClientError now carries the HTTP status, and the queue passes retryable=False only for 400 and 413. 429, 408 and server errors are retried as before, and 401/403/404 are unchanged.

This comment was drafted with Claude Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants