fix: treat HttpStatus.UNKNOWN as retryable#70
Conversation
Co-authored-by: Chris Leonavicius <crleona@gmail.com>
Co-authored-by: Chris Leonavicius <crleona@gmail.com>
|
Cursor Agent can help with this pull request. Just |
Route UNKNOWN HTTP responses to immediate retry in
|
Co-authored-by: Chris Leonavicius <crleona@gmail.com>
There was a problem hiding this comment.
Pull request overview
Updates the SDK’s retry behavior so that HttpStatus.UNKNOWN (e.g., -1 / transient network failures) is treated as retryable, aligning it with TIMEOUT and FAILED handling to reduce event loss on ambiguous transport/server errors.
Changes:
- Treat
HttpStatus.UNKNOWNas retryable inResponseProcessor.process_response. - Update worker tests to assert retry + eventual success flow for
UNKNOWNresponses. - Add a focused unit test ensuring
UNKNOWNdoes not trigger callbacks and incrementsevent.retry.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/amplitude/processor.py |
Adds HttpStatus.UNKNOWN to the retryable status set. |
src/test/test_worker.py |
Updates the unknown-status worker test to validate retry behavior; introduces a helper to wait for worker idleness in the multithreading test. |
src/test/test_processor.py |
Adds a unit test for ResponseProcessor retry behavior on UNKNOWN. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
bugbot run |
Co-authored-by: Chris Leonavicius <crleona@gmail.com>
|
Bugbot run |
Summary
Implements the suggestion from issue #69 to treat
HttpStatus.UNKNOWNresponses as retriable, similar toTIMEOUTandFAILEDstatuses. This enhances the SDK's resilience by preventing immediate event loss for unrecognized server responses.ResponseProcessornow pushes events back to storage for retry onHttpStatus.UNKNOWN.test_worker.pyto assert retry behavior forUNKNOWNresponses.test_processor.pyto specifically coverUNKNOWNstatus retry logic.Checklist
Note
Low Risk
Small, localized change to retry classification plus test updates; primary risk is altered behavior for
UNKNOWNresponses potentially causing extra retries in edge cases.Overview
ResponseProcessor.process_responsenow treatsHttpStatus.UNKNOWNas a retryable response, pushing affected events back to storage instead of immediately invoking callbacks/logging an error.Tests are updated/added to verify
UNKNOWNresponses incrementevent.retry, requeue events, and only trigger callbacks after a subsequent successful send; the worker multithreading test also replaces a busy-wait with await_for_workers_idle()helper to reduce flakiness.Written by Cursor Bugbot for commit 2666568. This will update automatically on new commits. Configure here.