Skip to content

fix(rest/nodejs): bump @ucp-js/sdk to 0.4.5 so quantity bounds hold at the schema boundary - #199

Open
vishkaty wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:fix/bump-sdk-quantity-bounds
Open

fix(rest/nodejs): bump @ucp-js/sdk to 0.4.5 so quantity bounds hold at the schema boundary#199
vishkaty wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:fix/bump-sdk-quantity-bounds

Conversation

@vishkaty

Copy link
Copy Markdown
Contributor

What

The pinned @ucp-js/sdk 0.4.3 generates LineItemCreateRequestSchema and LineItemUpdateRequestSchema with quantity as a bare z.number(), so a create or update carrying quantity 0, a negative quantity, or a fractional quantity crosses validation and is priced; a negative quantity produces negative checkout totals (#194).

Fix

Bump to 0.4.5, which restores the line_item.json contract, integer with minimum 1, at both request schemas (js-sdk#53). One code touch rides along: 0.4.5 types date-time fields as strings, so the single Date valued assignment, the shipped event occurred_at, moves to toISOString, same wire bytes, sound types.

Testing

  • New test/quantity_bounds.test.ts pins the boundary: 0, -1 and 1.5 draw 422 on create, -1 draws 422 on update, and a positive integer still prices normally, total 7000 for quantity 2 at 3500. All three rejection tests fail on 0.4.3 and pass on 0.4.5.
  • Full suite 158 passing on the bump; tsc and the pinned pre-commit are clean.
  • The Python reference already rejects these bodies at its schema boundary, so both lanes now agree.

Fixes #194.

…t the schema boundary

The pinned 0.4.3 generates LineItemCreateRequestSchema and
LineItemUpdateRequestSchema with quantity as a bare z.number(), so a
create or update carrying quantity 0, a negative quantity, or a
fractional quantity crossed validation and was priced, producing
negative checkout totals for negative quantities (Universal-Commerce-Protocol#194). 0.4.5
restores the line_item.json contract, integer with minimum 1, at both
request schemas. The new tests pin the boundary: 0, -1 and 1.5 draw
422 on create, -1 draws 422 on update, and a positive integer still
prices normally. Fixes Universal-Commerce-Protocol#194.

0.4.5 also types date-time fields as strings, so the one Date valued
assignment moves to toISOString, same wire bytes, sound types.
@damaz91 damaz91 added status:needs-triage Signal that the PR is ready for human triage status:under-review and removed status:needs-triage Signal that the PR is ready for human triage labels Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node checkout accepts quantity 0 and negative quantity, producing negative checkout totals

3 participants