fix(rest/python): deliver the order object as the webhook body#140
Merged
damaz91 merged 3 commits intoJul 23, 2026
Merged
Conversation
The order webhook (orderEvent) is defined in rest.openapi.json with a request
body of $ref: order — the delivered body must be an order object. The server
instead posted a custom envelope {event_type, checkout_id, order}, and posted it
even when there was no order (body = null).
Post the order object as the JSON body, carry the event type in an X-Event-Type
header (per the reporter's suggestion), and skip delivery when there is no order.
Adds two tests that capture the delivered request: the body validates as an
Order with all required top-level fields and no envelope keys, the event type is
in X-Event-Type, and no delivery occurs without an order. Fixes Universal-Commerce-Protocol#135.
Contributor
|
Approved. I'll make sure conformance test suite is also update to support this change before merging. |
damaz91
approved these changes
Jul 23, 2026
Contributor
|
I included the changes in Universal-Commerce-Protocol/conformance#63 - we can merge both at the same time once approved |
Resolves conflicts in rest/python/server/integration_test.py. TAG=agy CONV=f0d818cd-0531-40ee-880f-865ddf2b2a5f
nicholasjameshall
approved these changes
Jul 23, 2026
Address review comment suggesting using respx to simplify mocking of httpx. Removed custom _CapturingAsyncClient and updated _notify_and_capture to use respx.mock. TAG=agy CONV=94ff3e71-a493-4097-9827-22e9aeda899c
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.
Fixes #135.
What
The order webhook (
orderEventinsource/services/shopping/rest.openapi.json)defines its request body as
{"$ref": "order"}— the delivered body must be anorder object. The Python server instead posted a custom envelope
{event_type, checkout_id, order}, and posted it even when there was no order(body
null).This posts the order object as the JSON body, carries the event type in an
X-Event-Typeheader (the reporter's own suggestion), and skips delivery whenthere is no order — so the body is always a valid order.
Tests
Adds two tests to
integration_test.pythat capture the delivered webhookrequest (
httpx.AsyncClientstubbed by a capturing fake, driven through a realcreate+complete):
test_webhook_delivers_the_bare_order_as_body— exactly one POST; body passesOrder.model_validate()with all required top-level fields(
ucp, id, checkout_id, permalink_url, line_items, fulfillment, currency, totals);no
event_type/nested-orderenvelope keys; event type inX-Event-Type.test_webhook_is_skipped_when_there_is_no_order— no delivery when order absent.Both fail on the old envelope and pass on the fix.
Verification
ruff check+ruff format --checkclean;pre-commit runall hooks pass.Note: the Node.js sample has the same envelope in
rest/nodejs/src/api/checkout.ts;this PR scopes only the Python server per the issue — happy to send a parallel
Node.js fix if useful.