fix: Reject the retries option with a custom transport - #642
Open
razor-x wants to merge 2 commits into
Open
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y1RzepycXEYA3LStfjt8cY
…it-o2iid9-09-transport-retries
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.
What
A caller-supplied transport silently disabled retries:
Seam(retries=Retry(total=5), httpx_options={"transport": MyTransport()})performed zero retries with no warning, while env-proxy transports kept them — so retry behavior depended on whetherHTTPS_PROXYhappened to be set (SDK audit finding M12). Caller-suppliedmountshad the same hole.Following the PHP wave's "an injected client is left untouched" decision (and the injected-client guard the audit praised in the Ruby SDK), the SDK now:
SeamInvalidOptionsErrorwhenretries=is explicitly passed together with a customtransportormounts— the caller who brings a transport owns its middleware, and mixing an explicit retry policy with a transport that bypasses it is always a silent lie. Both sync and async clients.retriesis not passed (status quo, now documented).httpx_retries.RetryTransport.The client's
retriesparameter default changes fromDEFAULT_RETRIEStoNone— behaviorally identical (the constructor already coalescedNoneto the default), but it makes "explicitly passed" well-defined end-to-end. SDK-built transports, including env-proxy mounts, keep their default retry wrapping.Testing
New
test/custom_transport_test.py: the conflict raises with a pinned message (transport and mounts, sync and async); a custom transport withoutretriesmakes exactly 1 request against a 503-then-200 server; the documentedRetryTransportrecipe retries (request count 2, response succeeds).Revert check: with
seam/client.pyreverted to main, the conflict test fails withDID NOT RAISE— the audit's silent-acceptance symptom.Full suite: 190 passed; mypy, pylint (10.00), black, rstcheck clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Y1RzepycXEYA3LStfjt8cY
Generated by Claude Code