Repository navigation
fix(client): set default timeouts and check the token status - #425
rodrigojara-cko wants to merge 2 commits into
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: Looks good to meThis PR still needs a human approval — wall-e cannot auto-approve it. For what it's worth, I read the diff and found nothing I'd block on. Adds default connect/request timeouts to the SDK-created HTTP client and rejects non-200 token responses; the diff matches the stated intent and the new tests cover both behaviours correctly. What I checked
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 |
0dba770 to
ee30642
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 |
ee30642 to
9a9b381
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 HTTP client the SDK creates had no timeout, so a server that accepts the connection and never answers blocked the request forever. That client now uses connect_timeout 10 s and timeout 60 s, and a request over either bound fails with CheckoutApiException (CheckoutException on the OAuth token request). Behaviour change: before, no timeout; now 10 s to connect and 60 s for the whole request. A client passed with httpClientBuilder(), including a DefaultHttpClientBuilder built with your own config, is used as is and does not get these defaults; set connect_timeout and timeout on it to override.
The token response was only checked for its body, so a response with a status other than 200, the success status of a token response, was accepted when its body was valid: any status when the HTTP client does not throw on error statuses (http_errors set to false), and with any client the 1xx, 3xx and 2xx other than 200 statuses Guzzle does not throw on. Such a response now throws CheckoutAuthorizationException with the message "OAuth token request failed with status <code>", through the new CheckoutAuthorizationException::tokenRequestFailed() factory.
9a9b381 to
50c3dec
Compare
🔴 Risk Classification: MAJORApproval route: AI Review + Human Approval Required Classification reasons
Operational gates
Files analysed: 6 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 HTTP client the SDK creates had no timeout (Guzzle's default, wait forever), so a request to an API that accepted the connection and never answered kept the caller waiting with no limit. That client now has a 10 second connect timeout and a 60 second total timeout. The token response is also accepted only with status 200.
Changes
lib/Checkout/AbstractCheckoutSdkBuilder.php: the client the SDK creates getsconnect_timeout10 andtimeout60 (DEFAULT_CONNECT_TIMEOUT_SECONDS,DEFAULT_TIMEOUT_SECONDS); a builder set withhttpClientBuilder()keeps its own options.lib/Checkout/OAuthSdkCredentials.php: a token response with a status other than 200 throwsCheckoutAuthorizationException; its message comes fromtokenStatusMessage(), now shared withtokenFailureMessage()("OAuth token request failed with status", plus the OAuth error code when the server sent one).README.md: an "HTTP timeouts" section with the defaults, the exceptions and how to set other bounds; the custom CA client example sets timeouts.test/Checkout/Tests/HttpClientTimeoutsTest.php(new),test/Checkout/Tests/OAuthTokenStatusTest.php(new),test/Checkout/Tests/HttpClientOptionsTest.php(docblock).Design notes: the defaults go only on the client the SDK creates, never on a client the application configured. The token check accepts 200 only, the success status of a token response (RFC 6749 section 5.1), as the Java SDK does; with
http_errorsset to false the old code checked the body only. The status message has one source,tokenStatusMessage(), used both for an error status Guzzle throws and for one it returns. The exception type followshttp_errors: with Guzzle's default (true) an error status is thrown by Guzzle and keeps the existingCheckoutException, as does any other failure of the request; withhttp_errorsset to false the response comes back to the SDK, which throwsCheckoutAuthorizationExceptionlike the existing invalid token response check. Guzzle'stimeoutis a total for the request, so 60 seconds also bounds a large upload or report download; the README says to pass a client with a longertimeoutfor those. A token request that times out keeps the existingCheckoutExceptionand its message ("OAuth token request failed: GuzzleHttp\Exception\ConnectException (cURL error 28)").DEFAULT_CONNECT_TIMEOUT_SECONDSandDEFAULT_TIMEOUT_SECONDSare public so a custom client can reuse them. The tests against a server that never answers use a 1 second client, to check how the error surfaces; the default values are checked on the client configuration.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):
CheckoutApiException, or aCheckoutExceptionfor a token request, instead of waiting with no limit. This cannot be kept compatible: the bound is the fix. Migration: to use other bounds, set aDefaultHttpClientBuilderwith your owntimeoutandconnect_timeoutthroughhttpClientBuilder().CheckoutAuthorizationException, with any client: withhttp_errorsset to false any such status, and with the default client a 2xx other than 200 or a 3xx that is not followed. These responses used to be accepted when the body looked valid. Kept strict because a token from a response that is not a success is not a valid token. Migration: none expected; the token endpoint answers 200 on success.Tests
The new tests check the defaults on the client the SDK creates (static keys, OAuth and the Previous platform), a custom client keeping its options, an API request and a token request against a local server that never answers (the client secret absent from the token error), token responses with nine statuses other than 200 rejected, a 400 keeping its OAuth error code, and 200 accepted.
Related
None.