fix(api): validate quantity on POST /api/user-cards #46

Merged
varutasu merged 1 commit from fix/scanner-user-cards-quantity-guard into main 2026-05-27 15:25:21 -04:00
varutasu commented 2026-05-27 15:23:43 -04:00 (Migrated from github.com)

Summary

  • Adds parseInt(quantity, 10) + NaN / < 1 validation to POST /api/user-cards, matching the contract already in pages/api/decks/[id]/cards.js
  • Prevents non-numeric quantity strings from corrupting user_cards.quantity on scanner add/increment paths

P2 follow-up from audit-redesign-scanner-flow-44.

Test plan

  • POST /api/user-cards with quantity: "abc" → 400
  • POST /api/user-cards with quantity: 0 → 400
  • Valid quantity: 2 increments owned count by 2
  • CI vitest 21/21

Made with Cursor

## Summary - Adds `parseInt(quantity, 10)` + NaN / `< 1` validation to `POST /api/user-cards`, matching the contract already in `pages/api/decks/[id]/cards.js` - Prevents non-numeric quantity strings from corrupting `user_cards.quantity` on scanner add/increment paths P2 follow-up from `audit-redesign-scanner-flow-44`. ## Test plan - [ ] `POST /api/user-cards` with `quantity: "abc"` → 400 - [ ] `POST /api/user-cards` with `quantity: 0` → 400 - [ ] Valid `quantity: 2` increments owned count by 2 - [ ] CI vitest 21/21 Made with [Cursor](https://cursor.com)
vercel[bot] commented 2026-05-27 15:23:48 -04:00 (Migrated from github.com)

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tcg-vault Ready Ready Preview, Comment May 27, 2026 7:23pm

Request Review

[vc]: #QucxOTUCLzAGVg2q6a58pd/SaYhgpams2D7mU3fs86g=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJ0Y2ctdmF1bHQiLCJwcm9qZWN0SWQiOiJwcmpfRjZXOEVvRkd3Y0g3aWVGcnRvRlNlOXdVVkFhNSIsImluc3BlY3RvclVybCI6Imh0dHBzOi8vdmVyY2VsLmNvbS9yYW5kYWxsLXN0aWxsd2VsbHMtcHJvamVjdHMvdGNnLXZhdWx0LzV6REdHZGo0ZFBjc1JuMUVCWkhVRVJGYnVxbmYiLCJwcmV2aWV3VXJsIjoidGNnLXZhdWx0LWdpdC1maXgtc2Nhbm5lci11cy03NmQwYzItcmFuZGFsbC1zdGlsbHdlbGxzLXByb2plY3RzLnZlcmNlbC5hcHAiLCJuZXh0Q29tbWl0U3RhdHVzIjoiREVQTE9ZRUQiLCJsaXZlRmVlZGJhY2siOnsicmVzb2x2ZWQiOjAsInVucmVzb2x2ZWQiOjAsInRvdGFsIjowLCJsaW5rIjoidGNnLXZhdWx0LWdpdC1maXgtc2Nhbm5lci11cy03NmQwYzItcmFuZGFsbC1zdGlsbHdlbGxzLXByb2plY3RzLnZlcmNlbC5hcHAifSwicm9vdERpcmVjdG9yeSI6bnVsbH1dLCJyZXF1ZXN0UmV2aWV3VXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL3ZlcmNlbC1hZ2VudC9yZXF1ZXN0LXJldmlldz9vd25lcj12YXJ1dGFzdSZyZXBvPXRjZy12YXVsdCZwcj00NiJ9 The latest updates on your projects. Learn more about [Vercel for GitHub](https://vercel.link/github-learn-more). | Project | Deployment | Actions | Updated (UTC) | | :--- | :----- | :------ | :------ | | [tcg-vault](https://vercel.com/randall-stillwells-projects/tcg-vault) | ![Ready](https://vercel.com/static/status/ready.svg) [Ready](https://vercel.com/randall-stillwells-projects/tcg-vault/5zDGGdj4dPcsRn1EBZHUERFbuqnf) | [Preview](https://tcg-vault-git-fix-scanner-us-76d0c2-randall-stillwells-projects.vercel.app), [Comment](https://vercel.live/open-feedback/tcg-vault-git-fix-scanner-us-76d0c2-randall-stillwells-projects.vercel.app?via=pr-comment-feedback-link) | May 27, 2026 7:23pm | <a href="https://vercel.com/vercel-agent/request-review?owner=varutasu&repo=tcg-vault&pr=46" rel="noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://agents-vade-review.vercel.sh/request-review-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://agents-vade-review.vercel.sh/request-review-light.svg"><img src="https://agents-vade-review.vercel.sh/request-review-light.svg" alt="Request Review"></picture></a>
github-actions[bot] commented 2026-05-27 15:24:00 -04:00 (Migrated from github.com)

Pipeline Health

Build + CI gates

Gate Status
Vercel build (Preview) pass
CI: Lint pass
CI: Schema map fresh skipped
Preview smoke pass
Visual diff ⏭ skipped or pending

Build runs on Vercel; this CI runs lint and schema-map drift only (no duplicate build).

Role reports

Role Status
Reviewer report pending
A11y audit pending
Design system audit pending

See individual comments above for details. This rollup updates automatically.

<!-- pipeline-rollup --> ## Pipeline Health ### Build + CI gates | Gate | Status | | --- | --- | | Vercel build (Preview) | ✅ pass | | CI: Lint | ✅ pass | | CI: Schema map fresh | ❌ skipped | | Preview smoke | ✅ pass | | Visual diff | ⏭ skipped or pending | _Build runs on Vercel; this CI runs lint and schema-map drift only (no duplicate build)._ ### Role reports | Role | Status | | --- | --- | | Reviewer report | ⏳ pending | | A11y audit | ⏳ pending | | Design system audit | ⏳ pending | See individual comments above for details. This rollup updates automatically.
Sign in to join this conversation.
No description provided.