Skip to content
This repository was archived by the owner on Nov 16, 2026. It is now read-only.

feat: report pagination limits and resize safe requests - #101

Merged
betegon merged 1 commit into
mainfrom
bt/pagination-budgets
Oct 1, 2026
Merged

betegon merged 1 commit into
mainfrom
bt/pagination-budgets

Conversation

@betegon

@betegon betegon commented Sep 28, 2026

Copy link
Copy Markdown
Member

Collection helpers now report why they stopped and retain a resume cursor only when it cannot skip discarded rows. This extends the existing methods from #100; bound and standalone helpers share the same implementation.

CLI and MCP

Adoption sketches; each consumer supplies its configured sentry instance:

const options = { path: { organization_id_or_slug: "example-org" } };

// CLI: collect one displayed batch; the CLI keeps cursor history.
const batch = await sentry.paginateUpTo.listOrganizationIssues(options, {
  limit: 250,
  startCursor: savedCursor,
}); // 100 + 100 + 50, when the server returns full pages
// Render batch.data; persist batch.nextCursor when present.

// MCP: cap both returned items and HTTP requests.
const toolBatch = await sentry.paginateUpTo.listOrganizationIssues(options, {
  limit: toolLimit,
  maxPages: 3,
});
// Format toolBatch.data and report toolBatch.stopReason.

stopReason is "exhausted", "limit", or "maxPages". Only "exhausted" means complete. Overshoot still trims safely and returns no cursor; reaching maxPages now preserves continuation.

Sizing is enabled only for audited forward cursors: organization/project issues (limit, max 100) and issue events (per_page, max 100 or 10 with full: true).

Frontend

The frontend can keep its page-at-a-time flow; fetchPage and its raw response remain unchanged:

const page = await sentry.fetchPage.listOrganizationProjects({
  ...options,
  query: { per_page: 25 },
  signal,
}, cursor);
// Existing adapter/cache owns page.data, page.response.headers and navigation.

0.x migration

// paginateAll previously returned an array.
const { data: projects, stopReason, nextCursor } =
  await sentry.paginateAll.listOrganizationProjects(options, { maxPages: 50 });

paginateAll also accepts startCursor. Removed keepCursorOnOvershoot; item/request budgets must be positive safe integers. Standalone imports remain available with the same new result contract.

Validation

Clean build, typecheck, 137 tests, and packed-package declarations + Node 26 HTTP smoke passed. No live Sentry requests or consumer migrations.

Remaining work / review notes

  • Projects cannot safely resize yet. Their OffsetPaginator encodes page size: a source-extracted probe with 100,100,50 returned rows 1–100,101–200,251–300. Keep their request size unchanged; audit the CLI's project aggregation before migration.
  • Broader sizing needs verified cursor capabilities, including older/custom self-hosted backends. Schema parameter names alone are insufficient.
  • CLI/frontend pilots and the TanStack adapter remain follow-ups. The SDK does not add history or caching.

Part of #99 and #93; neither is completed by this PR.

Return collection data with an explicit stop reason and safe continuation. Resize only audited forward-cursor operations, and leave page-number cursors unchanged. Document the 0.x aggregate-result migration and removal of the unsafe overshoot override.
@betegon
betegon marked this pull request as ready for review October 1, 2026 18:28
@betegon
betegon merged commit 41d82c6 into main Oct 1, 2026
11 checks passed
@betegon
betegon deleted the bt/pagination-budgets branch October 1, 2026 19:30
@betegon betegon mentioned this pull request Oct 16, 2026
8 of 39 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant