Repository navigation
feat(apidocs): Publish API index endpoint - #130369
Merged
Merged
Conversation
Mark GET /api/0/ as PUBLIC and document it so it reaches the public OpenAPI schema and the generated @sentry/api SDK. Clients use it to read the scopes of the token they hold. Assign the endpoint to Foundations, which owns the other auth and token introspection endpoints, and remove it from the unowned allowlist. Add ApiIndexResponse, reusing UserSerializerResponseSelf for the user. Give that type's options and flags fields descriptions and a concrete flags type. Authentication is optional, so the operation lists an empty security requirement next to auth_token. Refs #130351 Co-Authored-By: BYK <[email protected]>
This was referenced Nov 7, 2026
BYK
added a commit
to getsentry/toolkit
that referenced
this pull request
Nov 7, 2026
… revision operations (#2093) Next batch of moving the CLI onto `@sentry/api` generated operations (follows #2073, #2075, #2078, #2090). `@sentry/api` 1.49.0 publishes three endpoints the CLI already calls: | CLI function | Endpoint | Operation | Published by | | --- | --- | --- | --- | | `listTraceLogs` (`log list --trace`, `trace logs`) | `GET /organizations/{org}/trace-logs/` | `listOrganizationTraceLogs` | getsentry/sentry#130357 | | `listDashboardRevisionsPaginated` (`dashboard revisions`) | `GET /organizations/{org}/dashboards/{id}/revisions/` | `listOrganizationDashboardRevisions` | getsentry/sentry#130358 | | `restoreDashboardRevision` (`dashboard restore`) | `POST /organizations/{org}/dashboards/{id}/revisions/{rev}/restore/` | `restoreOrganizationDashboardRevision` | getsentry/sentry#130358 | These calls stop using `apiRequestToRegion` and behave the same as before: - The CLI's valibot schemas still validate each response, so schema mismatches still fail as "Unexpected response format". - Region routing goes through `getOrgSdkConfig`. - Pagination still uses the Link-header cursors, including the previous cursor for revisions. - 401/403 errors are still enriched by `unwrapResult`. - On the wire, `traceId` and `sort` are sent as single repeated params, the same as before. - The dashboard and revision ids are passed as strings with the same cast `getDashboard` uses. The SDK URL-encodes them the way the old code did. All three operations have `experimental: false`. Bumping to 1.49.0 also pulls in the 1.47.0 regen and 1.48.0's `experimental` flag. Typecheck and generated docs don't change. ### Still on the helpers | Call site | Endpoint | Waiting on | | --- | --- | --- | | `issues.ts` `getSharedIssue` (raw fetch) | `GET /shared/issues/{share_id}/` | getsentry/sentry#130359 merged after the 1.49.0 regen, so it needs the next release | | `releases.ts` set-commits | `GET /organizations/{org}/releases/{version}/previous-with-commits/` | same as above (#130359) | | `org-auth-tokens.ts` (3 sites) | list/create/delete `/organizations/{org}/org-auth-tokens/` | getsentry/sentry#130360 (auto-merging) | | `projects.ts` dsn-lookup | `GET /organizations/{org}/dsn-lookup/` | getsentry/sentry#130367 | | `auth.ts` | `GET /api/0/` (control silo) | getsentry/sentry#130369 | | `users.ts` | `GET /auth/` → `GET /users/me/` | getsentry/sentry#130368 | | `organizations.ts` | `GET /users/me/regions/` | #2091 replaces it with `listOrganizations` | | `traces.ts` / `logs.ts` | `GET /projects/{org}/{project}/trace-items/{id}/` | sentry publish PR still to come | | `preprod-artifacts.ts` | build assemble, snapshot archive status and trigger, snapshot create (zstd body) | sentry publish PRs still to come | | `projects.ts` | `GET /projects/?query=dsn:` fallback for old self-hosted servers | not public; needs a decision (see below) | These are the agreed exceptions: `trials.ts` (`/customers/*` and the product-trial PUT), snapshot `upload-options` and archive `?download`, `downloadBuildArtifact`'s install URL, chunk-upload server URLs, and `rawApiRequest` for `sentry api`. **Needs a decision:** the self-hosted DSN fallback from #2090 calls `GET /projects/?query=dsn:`, which isn't in the public schema. It needs to be added to the exception list for the lint rule, or dropped once old self-hosted versions age out. ### Testing - `pnpm run tsc` and `pnpm run lint` pass. - `pnpm run test` fails only on the 5 file-permission tests that also fail on `main` in the sandbox (`completions` ×2, `upgrade`, `db/resilient`, `dsn/code-scanner`), plus `@sentry/cli3to4`, whose codemod binary needs GLIBC 2.35. - Added unit tests for the revision list (cursors, schema rejection) and for restore (operation args, error naming). The trace-logs test now checks `traceId` and `sort` on the wire. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A80220b9d4c297e2a971f05dcb03af515 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A80220b9d4c297e2a971f05dcb03af515) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A80220b9d4c297e2a971f05dcb03af515/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
BYK
pushed a commit
to getsentry/toolkit
that referenced
this pull request
Nov 7, 2026
…-release and shared-issue operations (#2095) Next batch of moving the CLI onto `@sentry/api` generated operations. Stacked on #2093 (1.49.0). It gets retargeted to `main` once #2093 merges. `@sentry/api` 1.50.0 publishes five endpoints the CLI already calls: | CLI function | Endpoint | Operation | Published by | | --- | --- | --- | --- | | `listOrgAuthTokens` (`token list`) | `GET /organizations/{org}/org-auth-tokens/` | `listOrganizationAuthTokens` | getsentry/sentry#130360 | | `createOrgAuthToken` (`token create`) | `POST /organizations/{org}/org-auth-tokens/` | `createOrganizationAuthToken` | getsentry/sentry#130360 | | `deleteOrgAuthToken` (`token delete`) | `DELETE /organizations/{org}/org-auth-tokens/{id}/` | `deleteOrganizationAuthToken` | getsentry/sentry#130360 | | `getPreviousReleaseCommit` (`release set-commits`) | `GET /organizations/{org}/releases/{version}/previous-with-commits/` | `getOrganizationPreviousReleaseWithCommits` | getsentry/sentry#130359 | | `getSharedIssue` (share links in `issue view`), raw `customFetch` until now | `GET /organizations/{org}/shared/issues/{share_id}/` | `getOrganizationSharedIssue` | getsentry/sentry#130359 | All five operations have `experimental: false`. Behavior is unchanged: - **Org auth tokens** still go to the control silo, and `OrgAuthTokenSchema` still validates the responses. 401/403 errors are still enriched by `unwrapResult`. The token id goes into the path as-is, with the same `as unknown as number` cast as the other numeric-string ids. - **Previous release** routes by org through `getOrgSdkConfig`. The SDK encodes the version, and the silent fallback to `undefined` stays. - **Shared issue** calls the operation with `customFetch` rather than the authenticated transport, because a share URL's host may not be the logged-in one and must never get a bearer token. Custom headers stay URL-scoped (`applyCustomHeaders`). The CLI's "TLS certificate error", "Share link not found or expired", "Failed to resolve share link", "Share link returned invalid JSON" and missing-issue-ID errors are the same as before. The bump regenerates `plugins/sentry-cli/skills/sentry-cli/references/event.md`, which reorders the event fields from the schema regen. No fields were added or removed. ### Still on the helpers | Call site | Endpoint | Waiting on | | --- | --- | --- | | `preprod-artifacts.ts` | build assemble, snapshot archive status and start, snapshot create (zstd body) | shipped in 1.51.0 (getsentry/sentry#130371). The next stacked branch, `ref/cli-sentry-api-1.51`, is ready | | `projects.ts` dsn-lookup | `GET /organizations/{org}/dsn-lookup/` | getsentry/sentry#130367 | | `auth.ts` | `GET /api/0/` (control silo) | getsentry/sentry#130369 | | `users.ts` | `GET /auth/` → `GET /users/me/` | getsentry/sentry#130368 | | `organizations.ts` | `GET /users/me/regions/` | #2091 replaces it with `listOrganizations` | | `traces.ts` / `logs.ts` | `GET /projects/{org}/{project}/trace-items/{id}/` | sentry publish PR still to come | | `replays.ts` replay list | `GET /organizations/{org}/replays/` | `replay list --json` prints `info_ids`/`warning_ids`, which the generated `field` enum leaves out. Needs a sentry docs fix or a decision | | `projects.ts` | `GET /projects/?query=dsn:` fallback for old self-hosted servers | not public; needs a decision (see #2093) | These are the agreed exceptions: `trials.ts` (`/customers/*` and the product-trial PUT), snapshot `upload-options` and archive `?download`, `downloadBuildArtifact`'s install URL, chunk-upload server URLs, and `rawApiRequest` for `sentry api`. ### Testing - `pnpm run tsc` and `pnpm run lint` pass. - `pnpm run test` fails only on the 5 file-permission tests that also fail on `main` in the sandbox (`completions` ×2, `upgrade`, `db/resilient`, `dsn/code-scanner`), plus `@sentry/cli3to4`, whose codemod binary needs GLIBC 2.35. - The org-auth-token tests now go through the mocked SDK fetch and check the control-silo URL, method, body and error naming. The existing shared-issue tests (404, TLS, invalid JSON, missing id, header scoping) pass unchanged. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A80220b9d4c297e2a971f05dcb03af515 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A80220b9d4c297e2a971f05dcb03af515) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A80220b9d4c297e2a971f05dcb03af515/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
BYK
pushed a commit
to getsentry/toolkit
that referenced
this pull request
Nov 7, 2026
…hot calls (#2097) Next batch of moving the CLI onto `@sentry/api` generated operations. Stacked on #2095 (1.50.0), which is stacked on #2093 (1.49.0). Each PR gets retargeted as the one below it merges. `@sentry/api` 1.51.0 carries getsentry/sentry#130371, which publishes the mobile build assemble endpoint and the snapshot archive endpoints, and adds a typed body for snapshot create. These call sites in `lib/api/preprod-artifacts.ts` move onto the generated operations: | CLI function | Endpoint | Operation | `experimental` | | --- | --- | --- | --- | | `uploadBuild` assemble poll loop (`build upload`) | `POST /projects/{org}/{project}/files/preprodartifacts/assemble/` | `assembleProjectPreprodArtifact` | false | | `createPreprodSnapshot` (`snapshots upload`) | `POST /projects/{org}/{project}/preprodartifacts/snapshots/` | `uploadProjectPreprodArtifactSnapshot` | false | | `getSnapshotArchiveReady` (`snapshots download`) | `GET /organizations/{org}/preprodartifacts/snapshots/{id}/archive/` | `getOrganizationPreprodSnapshotArchiveStatus` | **true** | | `triggerSnapshotArchiveBuild` (`snapshots download`) | `POST /organizations/{org}/preprodartifacts/snapshots/{id}/archive/` (202 `{detail}`) | `startOrganizationPreprodSnapshotArchive` | **true** | The two archive operations are marked experimental (`PUBLIC_EXPERIMENTAL` in sentry). They still move, and the planned lint rule will warn on them. Behavior is unchanged: - The CLI's valibot schemas still validate each response (`BuildAssembleResponseSchema`, which also reads `detail` on error states, `CreateSnapshotResponseSchema` and `SnapshotArchiveStatusSchema`). Error messages, 401/403 enrichment and org region routing (`getOrgSdkConfig`) are the same. - Snapshot create is still zstd-compressed with `Content-Encoding: zstd`, and still falls back to plain JSON when the runtime lacks zstd. That was the only user of the `bodyEncoding` option on `apiRequestToRegion`, so this PR removes the option. - Chunk uploads still go to the org region from `resolveOrgRegion`. Only the assemble call moved. - The build and snapshot request bodies are now typed from the schema instead of `Record<string, unknown>`. `vcsInfoToBody` returns a new `VcsBody` type, and `snapshots upload` builds a typed `SnapshotManifest`. ### Question for the reviewer: assemble transport retries The CLI still lets the transport retry the assemble POST, through `getOrgSdkConfig({ idempotent: true })`, as it did before this PR. Sentry now declares the opposite: the endpoint sets `idempotent_methods = frozenset()`, with a comment that a resend after the build leaves the uploading state creates another build, and the 1.51 docs say not to resend a request that succeeded. Server-side, `create_preprod_artifact` does `get_or_create(..., state=UPLOADING)`, so a resend that arrives while the build is still uploading reuses the same row. The poll loop returns as soon as it gets `artifactUrl`, so polling never re-sends after creation. The only risk is a transport retry after a lost response that lands once assembly has moved the build out of `UPLOADING`. I kept the retry so behavior doesn't change in this PR. Dropping it is a one-line change (`getOrgSdkConfig()`) if you'd rather follow Sentry's declaration. ### Still on the helpers | Call site | Endpoint | Waiting on | | --- | --- | --- | | `projects.ts` dsn-lookup | `GET /organizations/{org}/dsn-lookup/` | getsentry/sentry#130367 | | `auth.ts` | `GET /api/0/` (control silo) | getsentry/sentry#130369 | | `users.ts` | `GET /auth/` → `GET /users/me/` | getsentry/sentry#130368 | | `organizations.ts` | `GET /users/me/regions/` | #2091 replaces it with `listOrganizations` | | `traces.ts` / `logs.ts` | `GET /projects/{org}/{project}/trace-items/{id}/` | sentry publish PR still to come | | `replays.ts` replay list | `GET /organizations/{org}/replays/` | `replay list --json` prints `info_ids`/`warning_ids`, which the generated `field` enum leaves out. Needs a sentry docs fix or a decision | | `projects.ts` | `GET /projects/?query=dsn:` fallback for old self-hosted servers | not public; needs a decision (see #2093) | These are the agreed exceptions: `trials.ts` (`/customers/*` and the product-trial PUT), snapshot `upload-options` and archive `?download`, `downloadBuildArtifact`'s install URL, chunk-upload server URLs, and `rawApiRequest` for `sentry api`. `apiRequestToRegionNoContent` has no callers in `src` after this PR. It's still exported and used by `script/lib/source-api-usage.ts` and two tests, so it'll be removed with the other helpers in the lint-rule PR. ### Testing - `pnpm run tsc` and `pnpm run lint` pass. Generated docs and `command-api.json` don't change. - `pnpm run test` fails only on the 5 file-permission tests that also fail on `main` in the sandbox (`completions` ×2, `upgrade`, `db/resilient`, `dsn/code-scanner`), plus `@sentry/cli3to4`, whose codemod binary needs GLIBC 2.35. - `test/lib/api/preprod-artifacts.test.ts` now goes through the mocked SDK fetch. It checks the method, URL and decoded body for assemble, the zstd header and the decompressed manifest for snapshot create, the GET → POST → GET sequence for the archive wait, and a new case where a failed archive start throws `ApiError`. The `build` and `snapshots` command tests pass unchanged. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A80220b9d4c297e2a971f05dcb03af515 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A80220b9d4c297e2a971f05dcb03af515) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A80220b9d4c297e2a971f05dcb03af515/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
wedamija
approved these changes
Nov 9, 2026
BYK
added a commit
to getsentry/toolkit
that referenced
this pull request
Nov 9, 2026
…eveApiIndex (#2118) Bumps `@sentry/api` from 1.53.0 to 1.55.0 and moves the CLI's `GET /api/0/` call onto the generated `retrieveApiIndex` operation. getsentry/sentry#130369 published that endpoint, and 1.55.0 ships it. ## Change `getCurrentAuthScopes` (`packages/cli/src/lib/api/auth.ts`) feeds scope recovery. It used to call the raw `apiRequestToRegion(getControlSiloUrl(), "")` helper. It now calls `retrieveApiIndex` with `getSdkClientConfig(getControlSiloUrl())`, then `unwrapValidatedResult` with the same valibot schema. This is the same pattern as `org-auth-tokens.ts`. Behavior is unchanged: - It still goes to the control silo URL. That's the configured server URL on self-hosted, so self-hosted works as before. - `auth: null` still returns `null`. Sentry sends that for anonymous requests, session requests and requests with no token, and scope recovery treats it as `invalid`. - A 401 still comes back as an `ApiError` with `status: 401`. That's the case `scope-recovery.ts` checks. CLI errors thrown by the fetch layer, such as `AuthError`, still pass through `unwrapResult` unchanged. With this change, the API discovery step in `typecheck` no longer reports `auth.ts` as "not in the public catalog". ## Bump - `pnpm-workspace.yaml`: the catalog and `minimumReleaseAgeExclude` both move to `@sentry/[email protected]`. - `pnpm-lock.yaml`: the `@sentry/api` entries move to 1.55.0 and its integrity. 1.55.0 has the same dependencies and peer dependencies as 1.53.0. - `pnpm install --no-frozen-lockfile` wouldn't rewrite these entries. pnpm's lockfile age check rejected the old 1.53.0 entry before it resolved anything, even with 1.53.0 temporarily excluded, so I edited the entries by hand. - `pnpm install --frozen-lockfile` passes on the result, age policy check included. - 1.54.0 and 1.55.0 cause no other type errors. Neither the CLI docs nor the skill references changed when regenerated. ## Still waiting on sentry - dsn-lookup: getsentry/sentry#130367 - `/auth/` → `GET /users/me/`, falling back to `/auth/` on a 403 from older self-hosted servers: getsentry/sentry#130368 - trace items (`traces.ts`, logs): getsentry/sentry#130373 - After those, the no-allowlist Oxlint rule. ## Gate (local sandbox) - `pnpm run tsc`: passes. - `pnpm run lint`: passes. - Tests: - These all pass: mcp-core, mcp-cloudflare, mcp-test-client, toolkit-core, logger, apps/local, apps/docs-mcp, apps/games-api and apps/cli-docs. - CLI: 12952 pass and 5 fail. All 5 are the known sandbox-only permission cases: completions ×2, upgrade lock, resilient DB and the code-scanner unreadable-file test. - `@sentry/cli3to4` can't run here, because its `codemod` binary needs GLIBC 2.35. - `test/lib/api/auth.test.ts` now mocks `retrieveApiIndex` and covers scopes, `auth: null`, and the 401. No UI change, so no screenshots. Part of the `@sentry/api` migration that started in #2073 (tracking issue: getsentry/sentry#130351). <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A80220b9d4c297e2a971f05dcb03af515 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A80220b9d4c297e2a971f05dcb03af515) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A80220b9d4c297e2a971f05dcb03af515/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Burak Yigit Kaya <[email protected]>
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.
Part of the #130351 proposal to publish endpoints that the Sentry CLI (getsentry/toolkit) calls with raw requests today, so they appear in the public OpenAPI schema and in the generated
@sentry/apiSDK.This PR makes
GET /api/0/(IndexEndpoint, operationretrieveApiIndex)PUBLICand documents it.Evidence
PRIVATEin 2024 because it "basically does nothing". Its response hasn't changed since then, apart from feat(auth): Add deprecated scope translation layer #128663, which made it report stored scopes.GET /after a 403 to read the current token's scopes (getCurrentAuthScopes). That's why it needs to be in the SDK.Ownership
ApiOwner.FOUNDATIONS. Foundations already owns the other auth and token introspection endpoints, such asAuthIndexEndpointandApiAuthorizationsEndpoint, and this endpoint does the same kind of job: it reports who you are and what your credentials allow.ApiOwnerhas no API-platform team to pick instead./api/0/is removed fromapi_ownership_allowlist_dont_modify.py.api_ownership_stats_dont_modify.jsonis gitignored, so it doesn't change.Changes
ApiIndexResponsetype:version,auth: {scopes} | nullanduser: UserSerializerResponseSelf | null. I checked each field against the code.useris null for anonymous requests and for API keys and org auth tokens, because neither belongs to a user.authis null for session and anonymous requests.serialize(user, user), so it always returns the requester variant. That variant'soptionsfields (_UserOptions) get descriptions, andflags, which wasAny, becomes a_UserFlagsTypedDict.UserSerializerResponseSelfwasn't in the public schema before, and_UserOptionsonly appears in private endpoints, so no other public operation changes.security: [{auth_token: []}, {}], which lets SDK clients send a token without requiring one. drf-spectacular passes theauthlist through tosecurityunchanged, but its type annotation only allows scheme names. That's why that one line has a# type: ignore[list-item], with a comment saying why.UserExamples.RETRIEVE_API_INDEXexample and an apidocs test that validates the schema for a user token, an org auth token, and an anonymous request.Verification
make build-api-docson this branch and on master (ac2d476) and diffedopenapi-derefed.json. The only changes are the newGET /api/0/operation and theApiIndexResponsecomponent.python -m sentry.apidocs.response_coverage: 0 new gaps.pnpm run validate-api-examples: no errors.test_index.py, and the user serializer, user details and display preferences tests: 108 passed.pytest tests/apidocs tests/sentry/apidocs(-n4): 324 passed, 1 failed. The failure wastest_group_integration_details.py::test_get(500), which passes when run alone on this branch and on master. It's likely xdist flakiness unrelated to this change.tests/sentry/seer/endpoints/test_organization_agent_token.py: 325 passed, 23 xfailed.src/sentry/users/api/and the organization serializer, which use the changed user types, also passes.The "(Optional) Shows the difference between the prod and dev schema" check is expected to fail because this PR changes the schema.
via @BYK.
--
View Session [Sentry]