Skip to content

fix(python): return EXTENSION-RESPONSES on settle/verify - #4

Draft
PhilBot402 wants to merge 2 commits into
mainfrom
philbotextension-responses-f5e0
Draft

PhilBot402 wants to merge 2 commits into
mainfrom
philbotextension-responses-f5e0

Conversation

@PhilBot402

@PhilBot402 PhilBot402 commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Description

Python HTTPFacilitatorClient and HTTPFacilitatorClientSync logged the EXTENSION-RESPONSES header on successful verify/settle but never attached decoded extensions to VerifyResponse / SettleResponse. Callers expecting result.extensions got None when the facilitator sent extension metadata only in the header.

Root cause: _log_extension_responses_header in python/x402/http/facilitator_client.py decoded the header for logging, then _verify_http / _settle_http returned the body-parsed model without merging header extensions.

This change extracts header extensions, keeps the sanitized allowlist log, and attaches them when result.extensions is None. Body values win entirely ({} is preserved via is None, not truthiness). Malformed or non-object headers are ignored without failing payment success.

Related to x402-foundation#3270

AI disclosure: The majority of this PR was generated with Cursor Cloud Agent assistance; changes were reviewed and validated with unit tests.

Tests

From python/x402/:

uvx ruff format && uvx ruff check && uv run pytest tests/unit/http/test_facilitator_client.py -v

Added regression tests for header-only attach (async verify/settle, sync settle), body wins, empty body map wins, malformed header, and non-object JSON header.

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge)
  • I added a changelog fragment for user-facing changes (python/x402/changelog.d/4.bugfix.md)
Open in Web Open in Cursor 

PhilBot402 and others added 2 commits August 30, 2026 19:40
Attach decoded EXTENSION-RESPONSES header to VerifyResponse and SettleResponse when the JSON body omits extensions. Body values win; malformed headers do not fail payment success.

Co-authored-by: PhilBot <PhilBot402@users.noreply.github.com>
Co-authored-by: PhilBot <PhilBot402@users.noreply.github.com>
Eras256 added a commit to Eras256/Periplo that referenced this pull request Aug 30, 2026
Verified live before writing, none copied from the draft numbers as
given: #3278 (TS, Bartok9) still open; #3301 (Go, wnjoon), explicitly
refing #3270 and #3278 as a Go parity follow-up, open; PhilBot402/x402#4
(Python, a fork PR, still a draft), also linking back to #3270 directly,
open. Same format as the existing #3098/#3121 traction entries: dated,
evidence-linked, merge status stated plainly rather than assumed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Eras256 added a commit to Eras256/Periplo that referenced this pull request Aug 30, 2026
Not a new topic, the natural continuation of the same agentpayments.fi
integration story: that real settlement is what surfaced
x402-foundation/x402#3270 (HTTPFacilitatorClient discarding
EXTENSION-RESPONSES), now generating fixes in three separate SDKs.
Verified live before writing, none of the three changed since the last
check: #3278 (TS) open, #3301 (Go) open, PhilBot402/x402#4 (Python,
draft) open. Points to README.md's existing detailed block rather than
duplicating it. Section stays "1 minute," same format, no new section
number.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Eras256 added a commit to Eras256/Periplo that referenced this pull request Sep 3, 2026
- #3301 (Go) merged 2026-09-02T12:57:19Z by phdargen, verified against
  its real diff (ExtensionResponses field, leak-prevention regression
  test), closing the 'presumably needing the same realignment' gap.
  PhilBot402/x402#4 (Python) remains open in its own fork, never
  proposed against upstream.
- #3336 (feeBumpSigner) merged 2026-09-03T07:02:08Z by phdargen, given
  the same 'Own PR, merged <date> by <user>' credit already used for
  #103/#3306/#3278 instead of the stale 'fixed, not just filed'.

Both corrections found via a live README+docs sweep against the GitHub
API, not assumed from prior session state.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant