Repository navigation
fix(client): set default timeouts and check token status and subdomain - #427
rodrigojara-cko wants to merge 3 commits into
Conversation
🔴 Risk Classification: MAJORApproval route: AI Review + Human Approval Required Classification reasons
Operational gates
Files analysed: 9 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, rejects non-200 OAuth token responses, and fixes the subdomain regex to reject trailing newlines; all three changes are backed by targeted new tests and match the stated intent. 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 |
e4d61a1 to
69886aa
Compare
🔴 Risk Classification: MAJORApproval route: AI Review + Human Approval Required Classification reasons
Operational gates
Files analysed: 9 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 |
69886aa to
928fa10
Compare
🔴 Risk Classification: MAJORApproval route: AI Review + Human Approval Required Classification reasons
Operational gates
Files analysed: 9 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.
The subdomain pattern ended with $, which also matches before a final newline, so a value such as one read from a file with its line ending was accepted and placed in the request host. With the D modifier such a value is not used as a subdomain and the default host applies, as for any other value outside the pattern.
928fa10 to
bc9e614
Compare
🔴 Risk Classification: MAJORApproval route: AI Review + Human Approval Required Classification reasons
Operational gates
Files analysed: 9 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, and a subdomain with a trailing newline is no longer accepted. The timeout and token status changes of master, for the 3.2.x line, plus the trailing newline check of the subdomain that master already has (here the subdomain is not used instead of throwing, see Design notes). This line has no OAuth error code in the token messages, so the status message is the status only.
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.lib/Checkout/CheckoutAuthorizationException.php:tokenRequestFailed($statusCode)factory ("OAuth token request failed with status").lib/Checkout/EnvironmentSubdomain.php: the subdomain pattern gets theDmodifier, so$no longer matches before a final newline (master already has it).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/EnvironmentSubdomainTest.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 check is a new factory next to the existinginvalidAccessTokenResponse(). 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. With theDmodifier a subdomain with a trailing newline is treated like any other invalid subdomain on this line: it is not used and the default hosts apply, instead of the request failing later on the malformed host; master rejects it with an exception, which on this line would be a stricter change than the fix needs. 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 existingCheckoutExceptionwith the Guzzle message.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 patch of this line (3.2.11, 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), and token responses with nine statuses other than 200 rejected and 200 accepted, and a subdomain with a trailing newline not used.
Related
None.