Skip to content

fix: send Content-Digest and drop the removed request-signature header - #130

Open
ynachiket wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
ynachiket:fix/content-digest-129
Open

ynachiket wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
ynachiket:fix/content-digest-129

Conversation

@ynachiket

Copy link
Copy Markdown

Description

Fixes #129.

Every request from the suite carried a non-standard request-signature: test header, which was removed from the spec (ucp#636). The suite also never sent Content-Digest, which signatures.md requires (RFC 9530, sha-256=:<base64>: over the raw body bytes) on any request that has a body.

  • Remove request-signature from the default headers in framework/base_test.py and integration_test_utils.py.
  • Add framework/content_digest.py: compute_content_digest() and an httpx request event hook, add_content_digest, that sets Content-Digest whenever the request has a body (bodiless requests are untouched).
  • Install the hook on the shared client in BaseIntegrationTest.setUp, so every module gets it without per-test changes.
  • Add framework/content_digest_test.py: unit tests that need no server, including the RFC 9530 sha-256 example vector and a client-level check that the header is sent.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (none needed)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (see note)
  • Any dependent changes have been merged and published in downstream modules

Note: ruff check, ruff format --check, codespell and the new unit tests pass locally; all 87 existing tests still collect. The server-backed suites were not run locally (no merchant server available).

Every request carried a non-standard `request-signature: test` header that
was removed from the spec (ucp#636), and the suite never sent the
Content-Digest the signatures spec requires. Remove the header from the
default headers and install an httpx request hook on the shared client
that adds an RFC 9530 `sha-256` Content-Digest over the raw body bytes of
every request that has a body.

Fixes Universal-Commerce-Protocol#129
@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Nov 17, 2026
@williammacarini

Copy link
Copy Markdown

@ynachiket thanks for picking up #129. I opened #132 for the same fix without noticing this one, so I'm closing mine in favor of yours, which also has the unit tests and the RFC 9530 vector.

Since this PR notes that the server-backed suites weren't run, here's what I saw against a real server. I ran the full suite against Mercado Pago's business implementation (2026-08-25, REST binding), which rejects requests that have a body and no Content-Digest. The fix in #132 uses the same approach (an httpx request hook, and dropping request-signature).

passed failed errors skipped
main (0642adf) 3 55 0 25
with the hook 45 12 1 25

52 of the 55 failures on main were the missing Content-Digest. The 12 failures and 1 error left over are on the business side (order webhook, the simulation endpoints, and a 402 for a declined payment) plus #126, and none of them are related to this change.

@ynachiket

Copy link
Copy Markdown
Author

Thanks @williammacarini, and for closing #132 in favor of this one. Your run against Mercado Pago covers the gap the description notes, that the server-backed suites weren't run here. If you're happy with it, I'll add a one-line summary to the PR description: main 3 pass / 55 fail, with the hook 45 pass / 12 fail / 1 error, the remainder unrelated to this change.

@gswetha, when you have a moment, could you review this? All checks pass and there are no merge conflicts. The one red item is the Governance / Approvals status, which is the required-review gate, so it should clear once a maintainer approves. Nothing else needs fixing on my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:needs-triage Signal that the PR is ready for human triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suite sends the removed request-signature header and no Content-Digest, so digest-enforcing businesses reject every request

3 participants