Repository navigation
test(pagination): cover offsets across short pages - #118
Merged
Merged
Conversation
betegon
added a commit
to getsentry/toolkit
that referenced
this pull request
Oct 30, 2026
`sentry api --json` discarded pagination metadata, leaving agents
without a way to continue a successful query. It now exposes
continuation metadata and uses the CLI's shared cursor history for
`next`, `prev`, and `first`.
### Before
```sh
sentry api organizations/ -f per_page=1 --json
```
Even when another page existed, the output had no continuation (bodies
abbreviated):
```json
{"status":200,"statusText":"OK","body":[{"slug":"example-org"}]}
```
### After
The same command includes navigation metadata:
```json
{"status":200,"statusText":"OK","body":[{"slug":"example-org"}],"pagination":{"nextCursor":"1:1:0","hasPrev":false}}
```
Repeat the endpoint and filters to navigate:
```sh
sentry api organizations/ -f per_page=1 --cursor next --json
sentry api organizations/ -f per_page=1 --cursor prev --json
sentry api organizations/ -f per_page=1 --cursor first --json
```
Raw cursors and shared custom bookmarks are accepted, including legacy
`cli1~` bookmarks. Resuming restores the required page size and skips
rows already read; forward/back navigation retains that exact bookmark.
Arrays and Events `{data, meta}` envelopes are supported, preserving
envelope metadata.
### Shared SDK ownership
Uses published `@sentry/api@0.428.0`, including
getsentry/sentry-api-schema#116 and getsentry/sentry-api-schema#117. The
SDK owns generic URL, header, and body preparation through
`client.prepareRequest()`, plus partial-page consumption and bounded
traversal through `consumePage` and `paginateUpTo`. The API command uses
the same prepared `Request` for preview and dispatch, removing its
duplicate URL/header builders.
Toolkit keeps authentication and trusted-host checks, raw response
decoding, request/identity fingerprints, bookmark encoding, page-sizing
policy, and navigation history. The SDK accepts decoded server cursors
and offsets without depending on CLI storage or cursor formats. Existing
MCP and frontend consumers do not need to opt into request preparation.
Each `api` invocation still fetches one server page, and the endpoint
remains required. History is scoped to the request and identity;
dry-runs and failed requests do not advance it. `hasPrev` describes
local navigation, while `prevCursor` is server-provided. `--fields`
filters only the body. Raw text, binary downloads, explicit Content-Type
headers, and non-2xx response bodies retain their behavior. URL
fragments are excluded without losing encoded `#` characters. Command
help, docs, and the generated skill reference are updated.
Continuing without an endpoint is stacked in #1691. Native logs
pagination remains a separate follow-up.
Generic request preparation is tested in `@sentry/api`. Additional
coverage for continuation across short and empty pages is in
getsentry/sentry-api-schema#118, a tests-only follow-up that requires no
SDK release. The consumer tests concentrate on CLI navigation/history,
identity isolation, raw response policy, and bookmark adaptation.
### Validation
- Workspace typecheck and lint pass with published
`@sentry/api@0.428.0`.
- API and library E2E pass against the bundled CLI. Consolidated flows
retain navigation, dry-run/error recovery, raw-file preview and
dispatch, shared/legacy bookmarks, Events metadata, and request/identity
isolation. The silent request starts without JSON mode, then resumes
through the same saved history.
- Full workspace `pnpm run test` passes on Linux x64 on the final
source: 12,669 CLI tests, 337 shared tests, and all MCP, Cloudflare,
frontend, and remaining workspace suites. Existing skips remain
unchanged.
- Review and cleanup completed with no remaining findings. Production
code is unchanged by the test consolidation.
betegon
marked this pull request as ready for review
October 30, 2026 12:29
2 tasks done
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.
A saved continuation can cross pages shorter than its remaining offset, including an empty page. Cover
consumePageandpaginateUpTocarrying an offset of five through[1, 2],[], and[3, 4, 5, 6], returning only[6]while following opaque cursors.This keeps the generic continuation contract alongside its SDK implementation as consumer test duplication is reduced in Toolkit #1659. Only test coverage changes; no runtime, public API, or version changes.
Build, typecheck, all 254 Bun tests, and both Node cancellation tests pass.