feat: Only accept paginated requests in createPaginator - #1012
Open
razor-x wants to merge 4 commits into
Open
Conversation
createPaginator accepted any SeamHttpRequest, so paginating a non-paginated route typechecked and failed only at runtime, or after the hasPagination guard was added, with a runtime error instead of a compile error. Track pagination support in a SeamHttpRequest type parameter set by the generated route types, and constrain createPaginator to requests from paginated endpoints, so paginating a non-paginated route is a compile error. Runtime behavior is unchanged. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
…x115l-m11b-paginator-typegate
A bare boolean type argument in createPaginator's signature was opaque. Express the pagination gate through an exported SeamPaginatedRequest alias, used by createPaginator, SeamPaginator, and the generated request types of paginated endpoints, so signatures read as intent while non-paginated requests remain a compile error. Also merges main. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SDK audit finding M11b (medium):
createPaginatoraccepted anySeamHttpRequest, soseam.createPaginator(seam.devices.get({device_id}))orseam.createPaginator(seam.workspaces.list())typechecked and failed only at runtime. The accurateSeamHttpEndpointPaginatedQueryPathstype existed in codegen output but was consumed by nothing.Fix
Pagination support is tracked in a
SeamHttpRequesttype parameter and expressed through a named, exported alias so signatures read as intent rather than an opaque boolean:Generated request types of paginated endpoints are emitted as
SeamPaginatedRequest<...>(e.g.DevicesListRequest), so paginating a non-paginated route is a compile error. Runtime behavior is unchanged — the existinghasPaginationruntime guard remains for plain-JS callers. The type-parameter default isboolean, so existing user code holdingSeamHttpRequest<R, K>variables keeps compiling everywhere except at the new gate.Tests
@ts-expect-errorassertions:createPaginator(devices.get(...))andcreatePaginator(workspaces.list())are compile errors (on reverted source, typecheck fails — the audit's symptom that these compiled)Regenerated with
npm run generate. Full suite (154 tests), lint, typecheck green. Merged with latestmain.Part of applying the rev-3 SDK audit (one PR per finding). Related: #1002–#1011.
🤖 Generated with Claude Code
https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2