Skip to content

refactor(cli): use SDK page helpers for teams - #1508

Draft
betegon wants to merge 3 commits into
bt/cli-api-client-adoptionfrom
bt/cli-sdk-team-pagination
Draft

betegon wants to merge 3 commits into
bt/cli-api-client-adoptionfrom
bt/cli-sdk-team-pagination

Conversation

@betegon

@betegon betegon commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Stacked on client reuse #1502, after SDK upgrade #1507. Replace teams' per-page result unwrapping and Link-header handling with the SDK helper:

const sentry = await getOrgSentryClient(orgSlug);
return sentry.fetchPage.listOrganizationTeams(
  {
    path: { organization_id_or_slug: orgSlug },
    query: { per_page: options.perPage ?? 25 },
    meta: { errorContext: "Failed to list teams" },
  },
  options.cursor,
);

One call still fetches one HTTP page and retains its Response. CLI aggregation, cursor history, JSON output and the other teams operations stay unchanged.

The shared error interceptor reuses existing CLI error mapping only for calls with meta.errorContext. HTTP/network guidance and existing auth/API errors are preserved; decoding and validation failures keep their original errors. Ordinary calls continue through their existing unwrap helpers.

Validation

116 focused tests and CLI typecheck pass on published SDK 0.356.0. Covers HTTP/network guidance, preserved auth/API errors, opt-in mapping and unchanged decoding/validation failures. Frozen installation and tag-based schema generation also pass; runtime changes are identical to the previously validated pagination implementation.

Eight actual CLI scenarios and 17 local HTTP requests preserve exact stdout/stderr/exit codes and request values. Only the ordering of cursor/per_page changes; the CLI cache already normalizes it. Synthetic credentials only; no production OAuth/deployment validation.

Order and rollback

#1507 → #1502 → this pagination step. Cancellation #1506 remains independent.

Uses the published SDK inherited from #1507. Reverting this PR restores CLI page handling while keeping client reuse and the SDK upgrade. Reverse the order when reverting earlier adoption steps.

@vercel

vercel Bot commented Oct 15, 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 15, 2026 6:52pm UTC

Request Review

@betegon
betegon force-pushed the bt/cli-api-sdk-upgrade branch from f597242 to 39e36ff Compare October 15, 2026 18:49
@betegon
betegon force-pushed the bt/cli-sdk-team-pagination branch from 8ff70a1 to b685478 Compare October 15, 2026 18:52
@betegon
betegon changed the base branch from bt/cli-api-sdk-upgrade to bt/cli-api-client-adoption October 15, 2026 18:52
betegon added a commit that referenced this pull request Oct 15, 2026
Upgrade the CLI from `@sentry/api@0.337.0` to the published `0.356.0`,
preserving its existing standalone calls and pagination. Adapt the SDK's
new HTTP error envelope once in the shared helper so error details,
permission/scope guidance and exit codes stay unchanged.

```ts
// Existing CLI call sites keep this shape.
const result = await listOrganizations({
  ...getSdkConfig(baseUrl),
});
return unwrapResult<SentryOrganization[]>(result, "Failed to list organizations");
```

The common helper reads `SentryApiError.body`, handles transport
failures without a `Response`, and detects falsy thrown values. Two
direct status reads are guarded. Schema generation supports the SDK's
optional-argument syntax and reads the schema from the installed
version's tag.

Uses the npm release and normal lockfile: no vendored package or
temporary schema pin. The release-age exception is limited to this
verified first-party version. MCP's SDK dependency stays unchanged.

### Validation

- Frozen install of npm `0.356.0` through the configured registry;
release tarball integrity verified. Schema generation maps all 256
endpoints from tag `0.356.0`.
- 434 focused tests, repository typecheck/lint, CJS/ESM bundles and five
package-export checks pass.
- Eight actual CLI scenarios and 17 local HTTP requests match `main`
exactly: stdout/stderr/exit codes and request method/path/query/body.
Includes cursor navigation, scope guidance and automatic team creation.
- Standalone SDK/CLI probes cover HTTP metadata, error-body adaptation,
failures without a response and pre-aborted requests. Local HTTP and
synthetic credentials only; no production OAuth/deployment validation.
- Full workspace run: non-CLI suites pass; CLI has 10,805 passed and 22
skipped. The baseline macOS installer assertion and missing Xcode
`actool` remain; no new failures.

### Compatibility and order

Targets `main` and can merge independently of
[#1502](https://linear.review/getsentry/toolkit/pull/1502),
[#1506](https://linear.review/getsentry/toolkit/pull/1506) and
[#1508](https://linear.review/getsentry/toolkit/pull/1508).

Adoption order: **this upgrade** → [client reuse and `sentry.*`
#1502](https://linear.review/getsentry/toolkit/pull/1502) → [SDK
pagination #1508](https://linear.review/getsentry/toolkit/pull/1508).
The [CLI cancellation fix
#1506](https://linear.review/getsentry/toolkit/pull/1506) remains
independent; this upgrade does not wire signals into every CLI command
or fix its adapter's in-flight cancellation.

Revert adoption steps in reverse order. Frontend integration remains
separate.
@betegon
betegon force-pushed the bt/cli-api-client-adoption branch 2 times, most recently from 167ac51 to 2a0ede6 Compare October 15, 2026 20:01

This branch was previously deployed

1 inactive deployment
Preview — b6854788 Deployed Oct 15, 2026 by vercel[bot]
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.

1 participant