Skip to content

fix: Leave pagination params out of the at least one parameter guard - #1008

Open
razor-x wants to merge 3 commits into
mainfrom
claude/js-sdk-audit-6x115l-m7-parameter-guard
Open

fix: Leave pagination params out of the at least one parameter guard#1008
razor-x wants to merge 3 commits into
mainfrom
claude/js-sdk-audit-6x115l-m7-parameter-guard

Conversation

@razor-x

@razor-x razor-x commented Aug 24, 2026

Copy link
Copy Markdown
Member

Problem

SDK audit finding M7 (medium): the "at least one parameter" runtime guard scanned every value in the params object, and the generated RequireAtLeastOne type spanned every parameter. So seam.accessCodes.list({ limit: 10 }) — naming no filter at all — satisfied both the type and the runtime guard (false assurance), and a paginated request satisfied the guard from page 2 onward purely because page_cursor was set. Pagination knobs are not filters.

Fix

Mirrors seamapi/php#474, applied at the codegen level:

  • codegen/lib/layouts/route.ts computes atLeastOneParameterNames — the endpoint's parameter names minus limit/page_cursor — and drops the guard entirely if that leaves nothing.
  • Generated request configs carry the list, and assertValidRequestParameters checks exactly those names instead of scanning every value.
  • Generated parameter types are now RequireAtLeastOne<{...}, 'device_id' | 'name' | …> over the same names, so the type level and runtime agree — { limit: 10 } alone no longer typechecks either.

Regenerated with npm ci && npm run generate; the diff is the two guard fields across route files (28 RequireAtLeastOne wrappers regenerated with keys, none dropped — no endpoint has only pagination params today).

Tests

  • accessCodes.list({ limit: 10 }) and accessCodes.list({ limit, page_cursor })At least one parameter is required for /access_codes/list (on reverted source this request sails past the guard onto the network — the audit's exact symptom)
  • accessCodes.list({ device_id, limit }) builds fine
  • existing guard tests unchanged and green

Full suite (127 tests), lint, typecheck green.

Part of applying the rev-3 SDK audit (one PR per finding). Related: #1002#1007.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2


Generated by Claude Code

The at least one parameter guard counted every parameter, so
accessCodes.list({ limit: 10 }) satisfied the guard, and the generated
parameter type, while naming no filter at all, and a page cursor alone
satisfied it from page two onward. Pagination knobs are not filters.

Generate an explicit atLeastOneParameterNames list that excludes limit
and page_cursor, use it for the runtime check instead of scanning every
value, and constrain the generated RequireAtLeastOne parameter types to
the same names so the type level and runtime agree.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
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.

2 participants