Fix retry logic for POST requests#119
Merged
hownowstephen merged 3 commits intomainfrom May 7, 2026
Merged
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.
washam-cio
approved these changes
May 7, 2026
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
Changes HTTP retry behavior and success-status handling for all client requests, which can affect error handling and timing in production; risk is mitigated by targeted unit tests.
Overview
Fixes
ClientBaserequest handling to treat any 2xx response as success (instead of only200) and to re-raiseCustomerIOExceptiondirectly so API 4xx/validation errors aren’t wrapped as retry failures.Updates the underlying
Retryconfiguration to actually retryPOST(and all methods) and to retry on transient 5xx responses viastatus_forcelist, with new unit tests validating the retry config and the updated status/exception behavior.Reviewed by Cursor Bugbot for commit 4ea47ee. Bugbot is set up for automated code reviews on this repo. Configure here.