Skip to content

feat(cli): expose api pagination and cursor continuation - #1659

Open
betegon wants to merge 2 commits into
mainfrom
bt/api-pagination-cursor
Open

betegon wants to merge 2 commits into
mainfrom
bt/api-pagination-cursor

Conversation

@betegon

@betegon betegon commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

sentry api --json discarded the server's Link pagination metadata, so agents could receive a valid page without knowing how to continue. The JSON envelope now includes usable pagination.nextCursor / pagination.prevCursor values, and GET requests accept an opaque --cursor token.

Before

sentry api organizations/ -f per_page=1 --json

Even when the server advertised another page, the output contained no continuation (bodies abbreviated):

{"status":200,"statusText":"OK","body":[{"slug":"example-org"}]}

After

The same command preserves the advertised cursor:

{"status":200,"statusText":"OK","body":[{"slug":"example-org"}],"pagination":{"nextCursor":"1:1:0"}}

Repeat the request with that token to read the next page:

sentry api organizations/ -f per_page=1 --cursor '1:1:0' --json

--cursor replaces existing cursor parameters from the URL or fields while preserving other parameters; --dry-run previews the same request. Each invocation still fetches one page. --fields filters only the body, so it retains pagination metadata. If the server advertises no usable cursor, pagination is omitted; that does not establish whether the underlying dataset was fully scanned.

Covered by a two-page CLI E2E flow, cursor replacement and dry-run/request checks, non-GET rejection, and a bundled sdk.api() test with an opaque token. URL fragments are excluded before composing the request, while encoded # characters in query values are retained; regression tests cover both existing-query and path-only URLs. Includes command help, docs, and the generated API skill reference. Logs pagination is deferred to a separate PR.

Validation

  • Workspace typecheck and lint passed on Linux.
  • All workspace package test suites passed: non-CLI suites on Linux ARM64; the complete CLI suite on Linux x64 with coverage (11,358 passed, 49 existing skips). The CLI run used a non-root user, real Git metadata, and an init process, matching the permission and process assumptions of its tests.
  • CLI bundle and all 48 API/library E2E tests passed against the rebuilt bundle. Both URL-fragment regression cases failed against the previous bundle and pass with the fix.

@vercel

vercel Bot commented Oct 25, 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 26, 2026 3:16pm UTC

Request Review

@betegon
betegon marked this pull request as ready for review October 26, 2026 15:13
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 26, 2026
@betegon
betegon force-pushed the bt/api-pagination-cursor branch from b4cb377 to 4fe80fe Compare October 26, 2026 15:16

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use the common pagination system in the repo now. We even have some custom cursors now. I'm surprised the lint rule did not catch this.

Otherwise, great change thanks a lot!

@BYK

BYK commented Oct 26, 2026

Copy link
Copy Markdown
Member

I'd even argue we should let omitting the endpoint and other args or something so one can do sentry api --cursor next to keep paging through? Or something closer to this?

This branch was previously deployed

1 inactive deployment
Preview — 4fe80fe4 Deployed Oct 26, 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.

2 participants