Skip to content

feat: update @sentry/api to 0.133.0 and adopt pagination improvements#915

Merged
BYK merged 4 commits intomainfrom
feat/migrate-to-sentry-api-pagination-wrappers
May 5, 2026
Merged

feat: update @sentry/api to 0.133.0 and adopt pagination improvements#915
BYK merged 4 commits intomainfrom
feat/migrate-to-sentry-api-pagination-wrappers

Conversation

@MathurAditya724
Copy link
Copy Markdown
Member

Update @sentry/api from 0.113.0 to 0.133.0 and adopt the new pagination type improvements. This eliminates 5 unsafe as { cursor?: string } casts, replaces 2 manual pagination loops with autoPaginate, and adds prevCursor support to PaginatedResponse.

Changes

  • @sentry/api ^0.133.0 — includes pagination wrappers (fetchPage_*, paginateAll_*, paginateUpTo_*), widened query types (cursor + per_page now typed), and prevCursor in link header parsing
  • infrastructure.tsPaginatedResponse<T> gains prevCursor?: string; unwrapPaginatedResult passes it through
  • projects.ts — manual 30-line pagination loop → autoPaginate one-liner; casts cleaned up
  • repositories.ts — manual 15-line pagination loop → autoPaginate; casts cleaned up
  • teams.ts, releases.ts, issues.ts, events.tsas { cursor?: string } casts narrowed/removed; multi-line result casts collapsed

What's NOT migrated (follow-up)

traces.ts, discover.ts, and dashboards.ts widget queries stay on raw apiRequestToRegion — they use Zod validation schemas and the SDK wrappers' error handling (plain Error) is incompatible with the CLI's ApiError/AuthError pipeline.

Testing

  • bun test test/lib/api-client.coverage.test.ts — 91/91 pass
  • npx tsc --noEmit — clean (no new errors)

Update @sentry/api from 0.113.0 to 0.133.0, which includes pagination
wrappers, prevCursor support, and widened query types (cursor and
per_page now declared on paginated endpoints).

Changes:

- Bump @sentry/api to ^0.133.0 in devDependencies
- Add prevCursor to PaginatedResponse type and unwrapPaginatedResult
- Replace manual pagination loops with autoPaginate in listProjects()
  and listAllRepositories(), eliminating ~40 lines of cursor management
- Narrow 5 unsafe `as { cursor?: string }` casts to typed alternatives
  now that cursor/per_page are in the SDK query types
- Remove unnecessary multi-line result casts in issues, events, teams
- Remove stale comments about per_page not being in the OpenAPI spec

The CLI keeps its own unwrapPaginatedResult (not the SDK's) because
the CLI's error pipeline depends on ApiError/AuthError types that the
SDK's unwrapResult does not preserve.

traces.ts, discover.ts, and dashboards.ts widget queries are left
on raw apiRequestToRegion — they use Zod validation schemas and the
error-type incompatibility makes migration to SDK wrappers non-trivial.
These will be addressed in a follow-up.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-915/

Built to branch gh-pages at 2026-05-05 11:57 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Codecov Results 📊

6664 passed | Total: 6664 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 58.33%. Project has 13545 uncovered lines.
❌ Project coverage is 76.59%. Comparing base (base) to head (head).

Files with missing lines (4)
File Patch % Lines
src/lib/api/releases.ts 9.09% ⚠️ 10 Missing
src/lib/api/infrastructure.ts 64.71% ⚠️ 6 Missing
src/lib/api/projects.ts 62.50% ⚠️ 3 Missing
src/lib/api/events.ts 0.00% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    76.63%    76.59%    -0.04%
==========================================
  Files          303       303         —
  Lines        57821     57849       +28
  Branches         0         0         —
==========================================
+ Hits         44308     44304        -4
- Misses       13513     13545       +32
- Partials         0         0         —

Generated by Codecov Action

@MathurAditya724 MathurAditya724 marked this pull request as ready for review May 5, 2026 00:08
@MathurAditya724 MathurAditya724 requested a review from BYK May 5, 2026 00:08
Comment thread src/lib/api/projects.ts
The refactor to use autoPaginate removed per-callsite warning logs
that fired when MAX_PAGINATION_PAGES was reached. Move the warning
into autoPaginate itself so all callers benefit from the truncation
notice.
Comment thread src/lib/api/projects.ts Outdated
…X_SAFE_INTEGER

Replace Number.MAX_SAFE_INTEGER with MAX_PAGINATION_PAGES * API_MAX_PER_PAGE
(50 * 100 = 5000) as the autoPaginate limit in listProjects and
listAllRepositories. This makes the row-count cap explicit and aligned
with the page-count safety net already inside autoPaginate.
@BYK BYK merged commit 423bfa2 into main May 5, 2026
25 checks passed
@BYK BYK deleted the feat/migrate-to-sentry-api-pagination-wrappers branch May 5, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants