Skip to content

fix(framework): send Content-Digest and drop the removed request-signature header - #132

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

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

Conversation

@williammacarini

Copy link
Copy Markdown

Description

Fixes #129.

Every request the suite sent carried request-signature: test, a non-standard header removed from the spec after 2026-01-23 (Universal-Commerce-Protocol/ucp#636), and no request carried Content-Digest. signatures.md binds a request body to its signature with RFC 9530 Content-Digest, and the header is required whenever a request has a body. A business that enforces the digest therefore rejected every mutating request, and most modules never got past setup.

This PR:

  • Adds add_content_digest, an httpx request event hook registered on the shared self.client. It sets Content-Digest: sha-256=:<base64>: over the raw body bytes on every request that has a body. Because it is a hook on the client, it also covers bodies the tests build by hand.
  • Drops request-signature from BaseIntegrationTest.get_headers and from the integration_test_utils.get_headers facade.

The digest is harmless for businesses that ignore it. Once #105 adds a signing-key slot, the same hook is where Signature-Input and Signature would go.

Evidence. Run against Mercado Pago's business implementation (2026-08-25), which enforces the digest on every request with a body:

Passed Failed Errors Skipped
main (0642adf) 3 55 0 25
this branch 45 12 1 25

On main, 52 of the 55 failures are Content-Digest header is missing or invalid during setup. The 13 left on this branch are gaps on the business side (order webhooks, the simulation and adjustment endpoints, the payment-decline status code) plus #126.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the style guidelines of this project (ruff format and ruff check pass)
  • 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 (no docs mention these headers)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works (the framework has no unit tests; evidence above is from a full suite run)
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

The pre-commit hooks could not run locally (corporate network blocks the node download for prettier), so CI is the first run of the full hook set.

🤖 Generated with Claude Code

…ature header

Every request carried `request-signature: test`, a non-standard header
removed from the spec after 2026-01-23 (ucp#636), and no request carried
`Content-Digest`. signatures.md requires the digest whenever a request
has a body, so a business that enforces it rejected every mutating
request and most modules never got past setup.

Register an httpx request event hook on the shared client that sets
`Content-Digest: sha-256=:<base64>:` over the raw body bytes, and drop
`request-signature` from both header helpers. The digest is harmless
for businesses that ignore it.

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
Author

Closing as a duplicate of #130, which fixes #129 the same way and adds unit tests. I posted the live-suite results there.

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

2 participants