Skip to content

fix: Send the page cursor when the request has no parameters - #1003

Open
razor-x wants to merge 3 commits into
mainfrom
claude/js-sdk-audit-6x115l-c3-paginator-cursor
Open

fix: Send the page cursor when the request has no parameters#1003
razor-x wants to merge 3 commits into
mainfrom
claude/js-sdk-audit-6x115l-c3-paginator-cursor

Conversation

@razor-x

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

Copy link
Copy Markdown
Member

Problem

SDK audit finding C3 (critical, runtime-verified): SeamPaginator only attached page_cursor to the next-page request when the original request's params/body was non-null. Every generated list route makes its parameters optional, so seam.createPaginator(seam.devices.list()) re-sends page 1 forever:

runtime: no-args flatten → bodies sent: ["", "", "", ""]      (cursor never attached)
        with-args      → {"limit":1}, {"limit":1,"page_cursor":"c1"}, …  (correct)

Against the real API this is an infinite request loop and, via flattenToArray(), unbounded memory. Every existing paginator test passed { limit: 1 } — exactly the input that hides the bug.

Fix

Build the next-page request data unconditionally, choosing params vs body by the request method (GET/DELETE → query params, otherwise body) — the same rule codegen uses for the original request.

Tests

New nock-controlled test: a no-argument devices.list() paginator must send page_cursor on the page-2 request and terminate. Verified per the audit-notes recipe: with the source fix reverted, the test fails with the audit's exact symptom (page-2 request goes out with no cursor and never matches); with the fix, the full suite (126 tests), lint, and typecheck are green.

Part of applying the rev-3 SDK audit (one PR per finding, mirroring seamapi/php#465#479). Related: #1002.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2


Generated by Claude Code

The paginator only attached page_cursor to the next page request when
the original request had non-null params or body. Every generated list
route has optional parameters, so paginating a route called with no
arguments re-sent the first page request forever: an infinite request
loop and unbounded memory growth in flattenToArray.

Build the next page request data unconditionally, choosing params or
body by the request method.

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