fix: accept 200 or 201 for checkout-session creation in test_buyer_consent - #78
Open
vishkaty wants to merge 1 commit into
Open
Conversation
…sent test_buyer_consent asserts an exact 201 for POST /checkout-sessions (business_logic_test.py:432), while the rest of the suite accepts [200, 201] for the identical operation. This is an internal inconsistency: 200 is a spec-legitimate outcome for this endpoint, so the exact-201 assert can fail a conformant server. Why 200 is legitimate (pinned 2026-04-08): the status-code table in specification/checkout-rest.md lists both 200 OK and 201 Created as success, neither bound to an endpoint; business outcomes are returned with HTTP 200 and the UCP envelope carrying messages (checkout-rest.md, normative), which applies to the create path; and the Idempotency-Key replay path does not pin a status. source/services/shopping/rest.openapi.json does document 201 as the create success response, but that responses map is non-exhaustive (it lists no 4xx/5xx either), so it is the illustrative happy path, not a MUST forbidding 200. The suite already accepts [200, 201] for this same operation in five sibling sites, including the shared create_checkout_session helper every other test uses: integration_test_utils.py:914, protocol_test.py:328, idempotency_test.py:60, fulfillment_structure_test.py:253, and validation_test.py:87. Line 432 is the sole outlier. The check stays sound: assert_response_status uses assertIn, so any status outside [200, 201] still fails.
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.
Description
test_buyer_consentasserts an exact201forPOST /checkout-sessions(
business_logic_test.py:432), while the rest of the suite accepts[200, 201]for the identical operation. This is an internal inconsistency:
200is aspec-legitimate outcome for this endpoint, so the exact-
201assert can fail aconformant server.
Why
200is legitimate here200 OKand201 Createdas success responses (checkout-rest.md, status table~L1254–1266); neither is bound to a specific endpoint.
carrying
messages(checkout-rest.md~L1275, normative) — this applies tothe create path, so a create that surfaces a business outcome legitimately
returns
200.Idempotency-Keyreplay) does not pin the replay status.
For completeness:
source/services/shopping/rest.openapi.jsondocuments201as the success response for
POST /checkout-sessions. That responses map isnon-exhaustive (it documents no
4xx/5xxeither), so it does not mandate201to the exclusion of the200cases above — it's the illustrative happypath, not a MUST that forbids
200.The suite's own convention
[200, 201]is already accepted for this same operation in five siblingsites, including the shared helper every other test creates sessions through:
integration_test_utils.py:914— the sharedcreate_checkout_sessionhelperprotocol_test.py:328idempotency_test.py:60fulfillment_structure_test.py:253validation_test.py:87business_logic_test.py:432is the sole outlier.Change
One line —
assert_response_status(response, 201)→assert_response_status(response, [200, 201]).The check stays sound:
assert_response_statususesassertIn, so any statusoutside
[200, 201](e.g.4xx/5xx) still fails.test_buyer_consentverifies consent persistence; session creation is scaffolding and the assert
carries no other creation-distinctness signal, so nothing is lost.
Category (Required)