Repository navigation
ref(toolkit-core): Share limit-bounded pagination with the MCP - #1683
Merged
Merged
Conversation
Moves page sizing, resume-safe cursor encoding, `paginate`, and `fetchAllPages` from the CLI into `@sentry/toolkit-core/pagination`, so the MCP can reuse them (task group 3 of the unify-sentry-api-layer proposal, #1669). The shared module does no I/O and has no logger, `ApiError`, or Valibot dependency. Callers pass the page cap and a warning sink; `paginate` reports `stoppedAtPageCap`, and `fetchAllPages` takes a row parser and returns a typed failure (`invalid-page`, `repeated-cursor`, `page-cap`). The CLI keeps thin wrappers with the same signatures, default limit, `SENTRY_MAX_PAGINATION_PAGES` cap, warnings, and `ApiError` messages, so behavior and imports are unchanged. `autoPaginate` and the `sentry-cli/no-manual-pagination` lint rule stay CLI-only. Co-Authored-By: BYK <burak.kaya@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
sentry-junior Bot
added a commit
that referenced
this pull request
Oct 27, 2026
Task group 3 moved paginate, fetchAllPages, page sizing, and cursor encoding into @sentry/toolkit-core/pagination behind CLI wrappers. Co-Authored-By: BYK <burak.kaya@sentry.io>
BYK
approved these changes
Oct 27, 2026
sentry-junior Bot
added a commit
that referenced
this pull request
Nov 3, 2026
Task group 3 moved paginate, fetchAllPages, page sizing, and cursor encoding into @sentry/toolkit-core/pagination behind CLI wrappers. Co-Authored-By: BYK <burak.kaya@sentry.io>
This branch was previously deployed
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.
Moves the CLI's pagination core into
@sentry/toolkit-core/paginationso the MCP can reuse it. This is task group 3 of the unify-sentry-api-layer proposal (#1669).What moved: page sizing (an even split over the fewest requests, at most 100 rows per page), resume-safe cursors (the skip count is written into
is_prevso the cursor stays a valid Sentry cursor, page-number cursors keep their page size, andcli1~cursors are still read),paginate, andfetchAllPages.The shared module does no I/O and doesn't depend on the CLI logger,
ApiError, or Valibot:paginatetakesmaxPagesand an optionalwarnsink, and returnsstoppedAtPageCap. The spec's "Bounded page count" requirement asks for a structured page-cap signal, so the MCP can report it instead of logging.fetchAllPagestakes a row parser and returns{ ok: false, reason }(invalid-page,repeated-cursor, orpage-cap) instead of throwing.The CLI keeps thin wrappers in
packages/cli/src/lib/api/infrastructure.tswith the same signatures, default limit,SENTRY_MAX_PAGINATION_PAGEScap, page-cap warning, andApiErrormessages. Existing imports and behavior don't change, and the CLI pagination tests pass without edits.autoPaginateand thesentry-cli/no-manual-paginationlint rule stay CLI-only. The lint rule only scans CLI source, so the loop in toolkit-core isn't covered by it.Tests:
packages/toolkit-core/src/pagination.test.tshas a case for eachsentry-api-paginationscenario: a limit above one page and a limit within one page, stopping inside a page, cursors that the API and older clients accept, page-number cursor page size, the page cap, and a repeated cursor. It also covers invalid pages, thefetchAllPagespage cap, and unreadablecli1~cursors. The README now documents the module.Checks:
pnpm run tsc,pnpm run lint,pnpm run docs:check, toolkit-core tests (401), and the CLI pagination, replay, and alert suites (319) pass locally.via BYK.
--
View Junior Session in Sentry