Fix retry logic for POST requests#119
Open
hownowstephen wants to merge 2 commits intomainfrom
Open
Conversation
urllib3's Retry defaults only retry idempotent methods, so POST requests (used by all SDK methods) were never actually retried despite the configurable retries parameter. This adds allowed_methods=None to retry on all HTTP methods, adds status_forcelist for 5xx server errors, and fixes error handling so 4xx responses aren't wrapped in a misleading "after N retries" message. Closes #76
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3c52872. Configure here.
With raise_on_status=False, exhausted 5xx retries silently return the response instead of raising MaxRetryError, so the "Failed after N retries" context message is never shown for server errors. The default (True) is correct: 4xx codes aren't in status_forcelist so they always return a response regardless, and 5xx exhaustion properly raises.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Retrydefaults exclude POST fromallowed_methods, so all SDK retries were silently no-ops. Setsallowed_methods=Noneto retry all HTTP methods.status_forcelist=[500, 502, 503, 504]so transient 5xx responses trigger retries.200was accepted;201,202,204etc. raised exceptions.except Exceptionand wrapped in "Failed after N retries" — nowCustomerIOExceptionis re-raised directly.Context
This is the most-reported issue in the repo (#76), active since 2021 with users hitting
ConnectionResetErrorin production. The root cause was identified by @skion: retry parameters were decorative for POST.Closes #76
Test plan
test_retry_config_allows_post— verifiesallowed_methods=Noneandstatus_forceliston built sessiontest_non_200_raises_without_retry_wrapper— 400 errors raise cleanCustomerIOExceptionwithout "retries" noisetest_2xx_status_codes_accepted— 200/201/202/204 all pass throughmake test— 31 tests)make lint)Note
Medium Risk
Touches core HTTP request/retry behavior; incorrect retry semantics or status handling could change how clients react to transient failures or non-200 successes.
Overview
Fixes
ClientBaserequest handling so all 2xx responses are treated as success (not just200) andCustomerIOExceptionfrom non-2xx responses is no longer wrapped in a misleading "failed after N retries" message.Updates the underlying urllib3
Retryconfiguration to actually retry POST/other methods (allowed_methods=None) and to retry on selected transient server errors viastatus_forcelist(500/502/503/504), with new unit tests covering retry config, non-2xx exception behavior, and acceptance of201/202/204.Reviewed by Cursor Bugbot for commit 4c97261. Bugbot is set up for automated code reviews on this repo. Configure here.