Repository navigation
fix(client): add default timeouts to the sdk http session - #271
Conversation
🔴 Risk Classification: MAJORApproval route: AI Review + Human Approval Required Classification reasons
Operational gates
Files analysed: 7 wall-e 2026.06.19-02 · policy |
🔬 Debug — why this classification?Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.
Kinds:
See issue #3 for the proposal to formalise this map as Appendix A of the standards doc. wall-e 2026.06.19-02 · debug |
🟠 Advisory review: Concerns worth a lookThis PR needs a human approval. Before you give it, these are the things I'd want resolved. Adds default 10s connect / 60s read timeouts to the SDK session and maps token timeout to CheckoutAuthorizationException; the implementation is largely correct but the positional-argument guard in DefaultTimeoutSession has an off-by-one that could silently drop the default timeout. Concerns
This is not an approval. wall-e cannot auto-approve this PR — it is an opinion to help whoever does. Advisory review · us.anthropic.claude-sonnet-4-6 · wall-e 2026.06.19-02 |
a21e5a3 to
e6ecfee
Compare
🔴 Risk Classification: MAJORApproval route: AI Review + Human Approval Required Classification reasons
Operational gates
Files analysed: 7 wall-e 2026.06.19-02 · policy |
🔬 Debug — why this classification?Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.
Kinds:
See issue #3 for the proposal to formalise this map as Appendix A of the standards doc. wall-e 2026.06.19-02 · debug |
e6ecfee to
dbf75a7
Compare
🔴 Risk Classification: MAJORApproval route: AI Review + Human Approval Required Classification reasons
Operational gates
Files analysed: 7 wall-e 2026.06.19-02 · policy |
🔬 Debug — why this classification?Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.
Kinds:
See issue #3 for the proposal to formalise this map as Appendix A of the standards doc. wall-e 2026.06.19-02 · debug |
dbf75a7 to
1f11bf8
Compare
🔴 Risk Classification: MAJORApproval route: AI Review + Human Approval Required Classification reasons
Operational gates
Files analysed: 7 wall-e 2026.06.19-02 · policy |
🔬 Debug — why this classification?Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.
Kinds:
See issue #3 for the proposal to formalise this map as Appendix A of the standards doc. wall-e 2026.06.19-02 · debug |
The session the SDK creates when no http_client_builder is set had no timeout, and requests waits forever by default, so a stalled connection blocked the caller indefinitely. Behaviour change: requests made through the SDK-created session now use a 10 second connect timeout and a 60 second read timeout, unless a timeout is passed for the call. A session returned by a custom http_client_builder is used as is; the README shows how to set bounds on it.
With the default timeouts a stalled token request now ends in a read
timeout. That error is not a ConnectionError, so the raw requests exception
reached the caller instead of an SDK exception.
The token request now raises CheckoutAuthorizationException("OAuth token
request timed out") for a read timeout, chained to the original error, with
a fixed message like the other token errors. A connect timeout is a
ConnectionError and keeps its message. API requests that time out keep
raising CheckoutException, now covered by a test against a server that
never answers.
Behaviour change, also with a session from http_client_builder that sets
its own timeout: a token request read timeout used to reach the caller as
requests ReadTimeout and is now CheckoutAuthorizationException.
1f11bf8 to
b280753
Compare
🔴 Risk Classification: MAJORApproval route: AI Review + Human Approval Required Classification reasons
Operational gates
Files analysed: 7 wall-e 2026.06.19-02 · policy |
🔬 Debug — why this classification?Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.
Kinds:
See issue #3 for the proposal to formalise this map as Appendix A of the standards doc. wall-e 2026.06.19-02 · debug |
|



Summary
The session the SDK creates had no timeout, so a request to an API that accepted the connection and never answered kept the caller waiting with no limit. Requests sent through that session now have a 10 second connect timeout and a 60 second read timeout, and a token request that times out raises an SDK exception.
Changes
checkout_sdk/default_http_client.py:DefaultTimeoutSession, arequests.Sessionthat setstimeout=(DEFAULT_CONNECT_TIMEOUT, DEFAULT_READ_TIMEOUT)(10 s, 60 s) on every request that does not pass its own;DefaultHttpClientBuildercreates it.checkout_sdk/oauth_credentials.py: a token request that times out while waiting for the response raisesCheckoutAuthorizationException("OAuth token request timed out"), chained to the original error; a connect timeout keeps the existing connection error.get_access_tokendocuments what it raises.README.md: a "Timeouts" section with the defaults, the exceptions, that the connect bound does not include the DNS lookup, and an example of a session with other bounds (anHTTPAdaptermounted on a plainSessionthat sets(5, 30)on every request that passes no timeout, by name or by position); the customHttpClientBuilderInterfaceexample keeps the defaults withDefaultTimeoutSession.tests/default_http_client_test.py(new),tests/api_client_timeout_test.py(new),tests/oauth_credentials_test.py,tests/checkout_test_utils.py(local server that accepts the connection and never answers).Design notes:
requestshas no session-wide timeout, so the SDK session sets it per request withsetdefault, which keeps a timeout passed by the call. A session fromhttp_client_builderis used as given: the SDK does not change a client the application configured. Unlike the Java SDK, the token request of a custom session gets no deadline from the SDK: Python token requests are not serialized (there is no lock inoauth_credentials.py), so a hung one blocks only its caller, and the merchant's session is used as is. A timeout passed by position is kept too:DefaultTimeoutSessionis public so an application can reuse it, and adding the default next to a positional timeout would raise aTypeError. A token read timeout is mapped toCheckoutAuthorizationExceptionwith a fixed message, as the Java SDK does for its token request, so callers handle every token failure with one exception type. A token response body that stops arriving is raised byrequestsas aConnectionError(requests/models.py,iter_content), so it keeps the existing "Unable to establish connection" message even though the connection was made; the comment and the docstring say so.DefaultTimeoutSessionis public so a custom session can reuse it, as the README shows;DEFAULT_CONNECT_TIMEOUTandDEFAULT_READ_TIMEOUTdocument the values.API Reference
None. No request or response changes.
Breaking changes
None in the public signatures. Behaviour changes, released as a minor version (a correction of requests that could wait with no limit):
http_client_builder.http_client_builderthat sets its own timeout, raisesCheckoutAuthorizationExceptioninstead of therequestsReadTimeout. Needed so a token failure is an SDK exception: the HTTP error and connection failures of the token request already are, and an API request that times out with such a session is already raised asCheckoutException(api_client.py, theexcept OSErrorbranch); the token read timeout was the onlyrequestsexception that reached the caller. Migration: code that catchesrequests.exceptions.TimeoutorRequestExceptionaround the SDK catchesCheckoutAuthorizationExceptioninstead (it is not anOSError).Tests
The new tests check the default on every request of the SDK session, a timeout passed by the call by name or by position, a custom session left untouched, an API request and a token request against a local server that never answers (each fails within the bound with the SDK exception), and the connection message kept for a token connect timeout.
Related
None.