fix: accept cursor param in session.toolkits() pagination#3019
Open
fix: accept cursor param in session.toolkits() pagination#3019
cursor param in session.toolkits() pagination#3019Conversation
The ToolRouterToolkitsOptionsSchema only accepted `nextCursor` as the pagination cursor field name. Users naturally pass `cursor` (the standard pagination convention), but Zod's safeParse silently strips unknown keys, causing the cursor to always be undefined and every page returning page 1. Add `cursor` as an accepted field alongside `nextCursor` (backward compat), with `cursor` taking priority when both are provided. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
The Please review and fix the vulnerabilities. You can try running: pnpm audit --fix --prodAudit output |
Contributor
Author
Post-PR Status UpdateBuild Checks
Codex Review
CI Status
E2E Testing
PR Comments
SummaryAll post-PR tasks complete. The only CI failure is a pre-existing CLI test issue on |
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.
Description
Fix HIGH severity bug:
session.toolkits()pagination is broken because the SDK'sToolRouterToolkitsOptionsSchemaonly acceptsnextCursoras the cursor field name, but users naturally passcursor(the standard pagination convention).Root cause: Zod's
safeParsesilently strips unknown keys. When a user passes{ cursor: "Mi0yMA==" }, Zod strips thecursorfield (not in schema), leavingnextCursorasundefined. The API call then receives no cursor → always returns page 1.Fix:
cursoras an accepted field inToolRouterToolkitsOptionsSchemaalongsidenextCursor(backward compatible)toolkits()method to usecursorfirst, falling back tonextCursorcursortakes priority when both are providedFiles changed:
ts/packages/core/src/types/toolRouter.types.ts— Addedcursorfield to options schemats/packages/core/src/models/ToolRouterSession.ts— Usecursor ?? nextCursorfor API callts/packages/core/test/models/toolRouter.test.ts— Added 3 new tests for cursor paramHow did I test this PR
vitest run test/models/toolRouter.test.ts— all 90 tests passed (including 3 new ones)cursorparam is correctly forwarded to APIcursortakes priority overnextCursorwhen both providedcurl "localhost:9900/api/v3/tool_router/session/trs_xxx/toolkits?limit=5"→ slugs: gmail, composio, github...curl "...?limit=5&cursor=Mi01"→ slugs: googlesheets, slack, supabase... (different items confirmed)Triggered by: soham@composio.dev | Source: slack
Session: https://zen-api-production-4c98.up.railway.app/dashboard/#/chat/zen-c34fbd50ad9d