Skip to content

fix(sdk): reject payment constraints without a type - #397

Draft
williammacarini wants to merge 2 commits into
google-agentic-commerce:mainfrom
williammacarini:feature/reject-unknown-payment-constraints
Draft

williammacarini wants to merge 2 commits into
google-agentic-commerce:mainfrom
williammacarini:feature/reject-unknown-payment-constraints

Conversation

@williammacarini

@williammacarini williammacarini commented Nov 13, 2026 •

Copy link
Copy Markdown

OpenPaymentMandate currently accepts a constraint such as {"foo": "bar"} as an empty ExecutionDate. No date limits remain to evaluate, so a malformed constraint can silently become a no-op.

Require mapping-based payment constraints to declare type before generated model defaults are applied. Known-type validation remains with Pydantic. Typed SDK constructors such as ExecutionDate() keep their existing default identifiers.

Register the pre-validation hook in the SDK generator, regenerate OpenPaymentMandate, and document the tested generator version. The protocol JSON schemas are unchanged, keeping this contribution within the SDK scope of CONTRIBUTING.md.

Fixes #395.

Validation

Tested source tree: cba3969079640f40328027dbeb5145cc52235c5c; published commit: f21731f26ee210820d92ea196f1cd4e6dd286a67.

  • 57 new regression cases pass, covering Python and JSON input, every payment constraint variant, malformed and unknown constraints, serialization round trips, typed constructors, iterable inputs and invalid containers.
  • Before the fix, the initial 52-case regression suite had 20 failures and 32 passes on Pydantic 2.12.5.
  • Full SDK suite with the patch: 243 passed, 2 failed.
  • Clean upstream baseline on the same environment: 186 passed, 2 failed. The two failures are identical:
    • kb_sd_jwt_intermediate_tests.py::test_verify_rejects_aud_mismatch
    • kb_sd_jwt_intermediate_tests.py::test_verify_rejects_nonce_mismatch
  • Ruff check, changed-file formatting and git diff --check pass.
  • Generator verification compares 24 Python files produced by the original and patched scripts with datamodel-code-generator 0.87.0, ignoring timestamp comments. Only open_payment_mandate.py changes semantically, and its regenerated content matches this patch.
  • Both generator scripts also reproduce an existing difference from the checked-in types/jwk.py: optional crv and alg defaults. That unrelated generated file is unchanged in this PR.

Environment: Python 3.12, Pydantic 2.12.5, pytest 9.0.2, datamodel-code-generator 0.87.0. These are SDK parsing and regression checks, not payment E2E tests or a claim of an unconditional authorization bypass.

CI follow-up

Register the existing SDK terms PISP, pisp, Pisps, pisps, datamodel and codegen in the spelling dictionary, and fix the generation guide heading and shell example formatting.

The initial Super-Linter run also reported 75 Biome errors in unchanged code/web-client and docs/assets files. This is the existing repository-wide scan described in #306 and #366; it is separate from this SDK patch.

This branch has not been deployed

No deployments
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.

[Bug]: Unknown constraint objects are silently coerced to an empty ExecutionDate instead of failing evaluation

1 participant