Repository navigation
fix(sdk): Receipt.verify() treats a naive created_at as UTC - #368
Merged
Merged
Conversation
The gateway signs created_at with an explicit offset, but on SQLite the
receipt it returns from MCP, replay and GET /v1/receipts/{id} carries a
naive timestamp. Receipt.verify() compared the two datetimes directly, and
an aware datetime never equals a naive one, so every genuine receipt
returned MISMATCH and the README short tool call example failed.
Normalize both sides to an aware UTC instant before comparing. Gateway
timestamps are always UTC, so a naive value is read as UTC. A different
instant, or the same wall time under another offset, still mismatches.
Fixes #358
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: CS <cs@CSs-MacBook-Pro.local>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pre-merge checks:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
PetrefiedThunder
added a commit
that referenced
this pull request
Nov 17, 2026
* chore(sdk-python): bump amw-sdk version to 0.5.1 Update version from 0.5.0 to 0.5.1 in: - pyproject.toml - src/b2a_sdk/__init__.py - src/b2a_sdk/client.py User-Agent - src/b2a_sdk/x402.py User-Agent - tests/test_trust_client.py version assertion Add CHANGELOG.md entry for 0.5.1 documenting the receipt verification timezone fix from PR #368 (commit 4bf3fd4, closes #358). This is a version-bump-only change carrying the already-merged fix. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Christopher <PetrefiedThunder@users.noreply.github.com> * chore(sdk-python): update gateway SDK version references to 0.5.1 Update gateway's well-known endpoint and test comment to reflect the SDK version bump from 0.5.0 to 0.5.1. This fixes the failing test_wedge_honesty.py::test_agent_json_sdk_integrations_are_honest test which verifies the gateway's advertised SDK version matches pyproject.toml. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Christopher <PetrefiedThunder@users.noreply.github.com> --------- Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Christopher <PetrefiedThunder@users.noreply.github.com>
This branch was successfully deployed
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 #358
Root cause
Receipt.verify()compared the signed claim'screated_atwith the receipt's owncreated_atas plaindatetimeobjects (sdk/python/src/b2a_sdk/models.py). The gateway signscreated_atwith an offset (...+00:00), but on SQLite the receipt it returns from MCP, replay andGET /v1/receipts/{id}is naive (...967141). An aware datetime never equals a naive one, so every genuine receipt returnedMISMATCHand the README "Short tool call" example failed.Fix
Both comparisons of
created_at(the typed field and the raw field loop) now go through_utc_instant(), which reads a naive value as UTC. Gateway timestamps are always UTC. A different instant, or the same wall time under another offset, still returnsMISMATCH.The gateway side (serializing stored receipts without an offset on SQLite) is not changed here. It sits outside the SDK area this PR covers, and older gateways will keep returning naive values anyway, so the SDK has to cope.
Verification
sdk/python/tests/test_call.py:client.call(...).verify()with a naivecreated_atisVERIFIEDfor bothamwandb2a_sdk, and two negative cases stayMISMATCH. The positive test fails onmainand passes here.partner.notes.write), using the README snippet throughimport amw: onmain,raw created_at: 2026-11-12T01:42:50.294923and verify returnsMISMATCH; on this branch it returnsVERIFIED.python -m pytest sdk/python/tests: 476 passed.uv build sdk/python: builds wheel and sdist.No CHANGELOG entry, to avoid conflicts with the sibling SDK fix PRs for #359 to #362 (#372, #374, #378, #380), which would touch the same section.
🤖 Generated with Claude Code
Note
Low Risk
SDK-only receipt verification logic with targeted tests; no auth or gateway serialization changes.
Overview
Fixes #358 by normalizing
created_atbefore equality checks inReceipt.verify(), so receipts returned from SQLite-backed gateways (naive ISO strings) no longer fail verification against offset-aware signed claims.Adds
_utc_instant()inmodels.pyand routes both the typed-field and raw-fieldcreated_atcomparisons through it, treating naive values as UTC while still MISMATCHing a different instant or a conflicting timezone offset.New tests in
test_call.pycover successfulclient.call(...).verify()with naive timestamps forb2a_sdkandamw, plus negative cases for wrong wall time and non-UTC offsets.Reviewed by Cursor Bugbot for commit c7fb719. Bugbot is set up for automated code reviews on this repo. Configure here.