Skip to content

ref(toolkit-core): Share limit-bounded pagination with the MCP - #1683

Merged
BYK merged 1 commit into
mainfrom
feat/shared-pagination
Oct 27, 2026
Merged

BYK merged 1 commit into
mainfrom
feat/shared-pagination

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Moves the CLI's pagination core into @sentry/toolkit-core/pagination so 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_prev so the cursor stays a valid Sentry cursor, page-number cursors keep their page size, and cli1~ cursors are still read), paginate, and fetchAllPages.

The shared module does no I/O and doesn't depend on the CLI logger, ApiError, or Valibot:

  • paginate takes maxPages and an optional warn sink, and returns stoppedAtPageCap. The spec's "Bounded page count" requirement asks for a structured page-cap signal, so the MCP can report it instead of logging.
  • fetchAllPages takes a row parser and returns { ok: false, reason } (invalid-page, repeated-cursor, or page-cap) instead of throwing.

The CLI keeps thin wrappers in packages/cli/src/lib/api/infrastructure.ts with the same signatures, default limit, SENTRY_MAX_PAGINATION_PAGES cap, page-cap warning, and ApiError messages. Existing imports and behavior don't change, and the CLI pagination tests pass without edits. autoPaginate and the sentry-cli/no-manual-pagination lint 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.ts has a case for each sentry-api-pagination scenario: 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, the fetchAllPages page cap, and unreadable cli1~ 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

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>
@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Oct 27, 2026 7:35pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 27, 2026
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
BYK merged commit 616fea1 into main Oct 27, 2026
32 checks passed
@BYK
BYK deleted the feat/shared-pagination branch October 27, 2026 22:28
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

1 inactive deployment
Preview — e89a995a Deployed Oct 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant