Repository navigation
fix(client): security hardening - #429
david-ruiz-cko wants to merge 5 commits into
Conversation
Improve error handling of CheckoutApiException, the OAuth token request and the API client logs, so a failed response is described without copying data the SDK does not control.
🔴 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 |
🟢 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. Security hardening that removes file paths and cookie headers from logs/exceptions, improves error handling for unreadable responses, and fixes an OAuth integration test to use 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 |
🔴 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 |
🔴 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 |
🔴 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 |
🔴 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
Security hardening and improved error handling of
CheckoutApiException, the OAuth token request and the API client logs. No changes to the public API;CheckoutUtilsgains three static helpers marked@internal, asdescribeFailureis.Changes
lib/Checkout/CheckoutApiException.php: security hardening ofhttp_metadataanderror_details; improved error handling when the response cannot be read; property docs.lib/Checkout/CheckoutUtils.php: new internal helpersresponseOf,statusOfandbodyOf, used by error handling;describeFailureuses them.lib/Checkout/OAuthSdkCredentials.php: improved error handling of the token request; unused import removed.lib/Checkout/ApiClient.php: security hardening of a log line.README.md:http_metadatadescribed.Design notes:
describeFailure: static,@internal, inCheckoutUtils, because the exception, the OAuth credentials and the API client read a failed response the same way. Each one returnsnullinstead of throwing, so error handling cannot fail while it builds its own error.rewind()andgetContents(), and the result is used only when it is text. The same code is backported to the maintenance lines, where an exception inside__toString()cannot be caught before PHP 7.4.http_metadata;getHttpMetadataand the metadata of successful responses are unchanged.CheckoutApiExceptionbuilds its metadata itself instead of callingCheckoutUtils::getHttpMetadata: it takes any PSR-7 response, leaves the cookies out, checks the type of each value and never throws, whilegetHttpMetadatais public, takes Guzzle's response and keeps every header of successful responses. Merging them would change that public method.http_metadatais built from any PSR-7 response, not only Guzzle's, and isnullwhen one of its values cannot be read or is not of the documented type.API Reference
None.
Breaking changes
None in the public API (the three new
CheckoutUtilshelpers are@internal). Behaviour changes (patch release):CheckoutApiException::$http_metadatano longer lists theSet-CookieandSet-Cookie2headers of the failed response. The API does not use cookies, so they are not part of its error data; there is no compatible way to keep a header and leave it out. Migration: none.CheckoutApiException::$http_metadatais now set for an HTTP client that returns a PSR-7 response other than Guzzle's, and isnullwhen the response's values cannot be read. Before, building it failed. Migration: none.error_detailsis an empty array and the exception is still raised. Before, the read error reached the caller. Migration: none.CheckoutException, as for any other token failure. Migration: none.POST <path>. Migration: none, unless code parsed the log.Tests
Existing tests pass (
vendor/bin/phpuniton PHP 8.4: 1793 tests, 0 failures, 0 deprecations; phpcs and phpstan clean)Serialization tests cover every new or changed property (no request or response type changes)
README updated if documented usage changed
test/Checkout/Tests/OAuthIntegrationTest.php: the OAuth payment allocates its amount to the sub-entity withamount_allocationsinstead of themarketplaceobject, which the payment request no longer has in the API and the sandbox now refuses.test/Checkout/Tests/ErrorHandlingTest.php: failed responses that cannot be read, a response with a text status code, a failed token request with an unreadable body, response headers kept with and without cookies, metadata of another PSR-7 response, the status taken from the response, and the upload log line. Most of the added lines are those response fixtures.Related
None.