fix(ack-pay): reject empty payment option identifiers - #183
Conversation
paymentOptionSchema accepted empty strings for id, currency, and recipient, and paymentRequestSchema accepted an empty request id, even though other fields such as amount already reject invalid values. Require a non-empty string for these fields in both the valibot and zod schemas.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. WalkthroughThe payment schemas now reject empty identifiers and fields. The Valibot amount string branch also requires a positive integer string. Parameterized tests cover both Valibot and Zod validators, and a patch changeset documents the update. ChangesPayment schema validation
Estimated code review effort: 2 (Simple) | ~15 minutes Merge Risk: ⚪ Minimal · up to Payment request and option schemas now consistently reject empty identifiers and related fields, with coverage for both supported validators. No merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This PR is currently conflicting with |
|
Conflicts with main are fixed. |
Problem
paymentOptionSchemaaccepted empty strings forid,currency, andrecipient, andpaymentRequestSchemaaccepted an empty requestid. Other fields already reject invalid values —amountmust be positive, and the zod schema rejects negativedecimals— so an all-empty option was not an intentional allowance, justv.string()/z.string()with no length check.A signed payment request token can carry those fields through to verification, so the schema is the gate for HTTP 402 bodies and anything that parses them with
verifyPaymentRequestToken.Fix
Introduce a shared
nonEmptyStringin both schema files and use it for the payment requestidand forid,currency, andrecipienton each payment option. Valibot and zod stay in sync, per the repo's dual-schema rule.Tests
Extended
schemas.test.tswith parity coverage: each schema rejects a payment option with an emptyid,currency, orrecipient, and rejects a payment request with an empty top-levelid.Patch changeset included for
@agentcommercekit/ack-pay.AI usage
Per AI_POLICY.md, Cursor did the work during a rescan of main: it measured the empty-string acceptance, wrote the schema change and parity tests, and added the changeset. I read the diff before opening this.
Summary by CodeRabbit
Bug Fixes
Tests
Documentation