Repository navigation
feat(apidocs): Publish x-sentry-project-scope on operations - #132722
Merged
Merged
Conversation
Add a project_scope declaration to Endpoint, published as the
x-sentry-project-scope operation extension. It says how a request names the
projects whose data it returns or changes: "path" (stamped automatically on
every path with {project_id_or_slug}), "filter" (the project query
parameter), "org-metadata" (read-only organization metadata), or
"response:<pointer>" (a GET by ID whose project ID is at a JSON pointer in
the response). The schema build validates declarations.
Clients such as the Sentry CLI and MCP server can then enforce a project limit
from the schema instead of a hand-written endpoint table.
Refs getsentry/toolkit#2237
Co-Authored-By: BYK <[email protected]>
The SCIM team details endpoint and the private insights tree and trace item attribute details/merged endpoints inherit a project_scope that was not checked against their handlers. Clear it so only the declared endpoints publish a value. Co-Authored-By: BYK <[email protected]>
sentry-junior Bot
added a commit
to getsentry/toolkit
that referenced
this pull request
Nov 27, 2026
The installed `@sentry/api` (1.74) has no `projectScope`, so the generated catalog list is empty and a project scope refused every endpoint the catalog covers, `chunk-upload/` included. A scoped `sourcemap upload` was refused before its token check. Until the `@sentry/api` 3.x bump, the rules come from `interim-project-scope-operations.json`, a copy of what getsentry/sentry#132722 declares. It was the tests' fixture, so the tests now run on the same rules the CLI enforces. Once the catalog has any declarations it wins, and a guard test checks that every interim entry is in it. The copy and `projectScopeDeclarations` are marked for deletion with the bump. Refs #2237 Co-Authored-By: BYK <[email protected]>
BYK
requested changes
Nov 27, 2026
BYK
added a commit
that referenced
this pull request
Nov 27, 2026
…132723) `@sentry/api/operations` now carries Sentry's `x-sentry-project-scope` OpenAPI extension, added in #132722, as `ApiOperation.projectScope`. Clients that limit a caller to some projects can read it instead of keeping their own endpoint table. getsentry/toolkit#2552 consumes it for the Sentry CLI and MCP project scope. ```ts export type ApiProjectScope = "path" | "filter" | "org-metadata" | `response:${string}`; // on ApiOperation readonly projectScope?: ApiProjectScope; ``` The values: - `path`: the path names the project. - `filter`: an organization endpoint that takes the `project` query parameter (numeric project IDs) and returns or changes only those projects' data. - `org-metadata`: a read-only organization endpoint whose response holds no project's telemetry. `GET` only. - `response:<pointer>`: a `GET` that looks something up by ID alone. The numeric ID of its project is at `<pointer>` in the response body. `<pointer>` is an RFC 6901 JSON pointer (`~0`/`~1` escapes) in which a `*` segment matches every array element, such as `response:/projects/*/id`. The field is left out when an operation has no extension, which means the operation is not known to respect a project limit. `ApiProjectScope` is exported from `@sentry/api/operations` next to `ApiOperation`. Like the `x-sentry-routing` check, the build throws on a non-string value, on an unknown value, on a malformed pointer, and on `org-metadata` or `response:` on a method other than `GET`. These are the same rules that #132722's schema build enforces. The released catalog has no `projectScope` values until #132722 merges and the schema is rebuilt. Refs getsentry/toolkit#2237 <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Aee8e94869cd8853bb9ac177d49cf5de5 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3Aee8e94869cd8853bb9ac177d49cf5de5) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Aee8e94869cd8853bb9ac177d49cf5de5/?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]>
sentry-junior Bot
added a commit
to getsentry/toolkit
that referenced
this pull request
Nov 27, 2026
The installed `@sentry/api` (1.74) has no `projectScope`, so the generated catalog list is empty and a project scope refused every endpoint the catalog covers, `chunk-upload/` included. A scoped `sourcemap upload` was refused before its token check. Until the `@sentry/api` 3.x bump, the rules come from `interim-project-scope-operations.json`, a copy of what getsentry/sentry#132722 declares. It was the tests' fixture, so the tests now run on the same rules the CLI enforces. Once the catalog has any declarations it wins, and a guard test checks that every interim entry is in it. The copy and `projectScopeDeclarations` are marked for deletion with the bump. Refs #2237 Co-Authored-By: BYK <[email protected]>
sentry-junior Bot
added a commit
to getsentry/toolkit
that referenced
this pull request
Nov 27, 2026
The installed `@sentry/api` (1.74) has no `projectScope`, so the generated catalog list is empty and a project scope refused every endpoint the catalog covers, `chunk-upload/` included. A scoped `sourcemap upload` was refused before its token check. Until the `@sentry/api` 3.x bump, the rules come from `interim-project-scope-operations.json`, a copy of what getsentry/sentry#132722 declares. It was the tests' fixture, so the tests now run on the same rules the CLI enforces. Once the catalog has any declarations it wins, and a guard test checks that every interim entry is in it. The copy and `projectScopeDeclarations` are marked for deletion with the bump. Refs #2237 Co-Authored-By: BYK <[email protected]>
sentry-junior Bot
added a commit
to getsentry/toolkit
that referenced
this pull request
Nov 27, 2026
The installed `@sentry/api` (1.74) has no `projectScope`, so the generated catalog list is empty and a project scope refused every endpoint the catalog covers, `chunk-upload/` included. A scoped `sourcemap upload` was refused before its token check. Until the `@sentry/api` 3.x bump, the rules come from `interim-project-scope-operations.json`, a copy of what getsentry/sentry#132722 declares. It was the tests' fixture, so the tests now run on the same rules the CLI enforces. Once the catalog has any declarations it wins, and a guard test checks that every interim entry is in it. The copy and `projectScopeDeclarations` are marked for deletion with the bump. Refs #2237 Co-Authored-By: BYK <[email protected]>
BYK
marked this pull request as ready for review
November 27, 2026 13:35
Stamp "filter" on every non-project-path operation that documents the project query parameter, instead of declaring it per endpoint. A declared value still wins. Fail the schema build when a "response:" pointer does not reach a string or integer field in the operation's 200 response schema. Refs getsentry/toolkit#2237
BYK
approved these changes
Nov 27, 2026
sentry-junior Bot
added a commit
to getsentry/toolkit
that referenced
this pull request
Nov 28, 2026
3.5.0 carries Sentry's x-sentry-project-scope declarations (getsentry/sentry#132722) as each operation's projectScope.
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.
Adds an
x-sentry-project-scopeoperation extension to the OpenAPI schema. It works likex-sentry-idempotent: the schema build stamps it on each operation before issue alias canonicalization.The Sentry CLI and MCP server limit a caller to an org or project at the HTTP transport, using a hand-written table of endpoint rules (getsentry/toolkit#2549). With this extension they can read the same facts from the schema through
@sentry/api/operations. Refs getsentry/toolkit#2237.What the value means
The value is a string on an operation (path + method). It says how the request names the projects whose data the operation returns or changes:
pathfilterprojectquery parameter (numeric project IDs) and returns or changes only those projects' data.org-metadataresponse:<pointer>GETlookup by ID alone. The numeric project ID of the object it found is at<pointer>in the response body.<pointer>is an RFC 6901 JSON pointer, plus a*segment that matches every element of an array, e.g.response:/projects/*/id.An operation with no value isn't known to respect a project limit.
Where values come from
The build derives two values from the schema:
pathon every operation whose path contains{project_id_or_slug}.filteron every other operation that documents theprojectquery parameter (OrganizationParams.PROJECTin@extend_schema).Endpoints declare the rest per method on the class, and a declared value wins over a derived
filter:Endpoint.project_scope: dict[HTTP_METHOD_NAME, str]defaults to{}. The build fails when:filter,org-metadata, orresponse:<pointer>(pathcan't be declared),response:ororg-metadatais on a method other thanGET,response:isn't a JSON pointer,$ref,allOf,oneOf,anyOf, and array items),publish_status,{project_id_or_slug}.Declarations are collected for unpublished endpoints too and reset on every build. Subclasses inherit them, like
idempotent_methods. The SCIM team details endpoint setsproject_scope = {}, so it doesn't inheritorg-metadatafrom team details. The rules are documented insrc/sentry/apidocs/README.md.Values in the schema
Paths are relative to
/organizations/{organization_id_or_slug}/unless shown otherwise.path(derived): 91 operations.filter(derived): 36 operations. These includeissues/(GET, PUT, DELETE), GET onevents/,events-timeseries/,events-dropped/,trace-items/attributes/,replays/,replay-count/,monitors/,detectors/,workflows/,releases/,agents/conversations/,issues-stats/,sessions/,tags/,stats_v2/, andprofiling/*, plus PUT/DELETE ondetectors/andworkflows/.response:(declared, GET):issues/{issue_id}/→response:/project/idreplays/{replay_id}/→response:/data/project_idmonitors/{monitor_id_or_slug}/→response:/project/iddetectors/{detector_id}/→response:/projectId(nullfor the all-projects detector)releases/{version}/→response:/projects/*/idorg-metadata(declared, GET): the organization itself,projects/,teams/,user-teams/,members/,members/{member_id}/,environments/,dsn-lookup/,chunk-upload/,integrations/,integrations/{integration_id}/(pluschannels/,repos/, andchannel-validate/),config/integrations/,available-actions/,sentry-apps/,sentry-app-installations/,sentry-app-components/,repos/,repos/{repo_id}/commits/,code-mappings/,dashboards/,dashboards/{dashboard_id}/,dashboards/{dashboard_id}/revisions/,discover/saved/,discover/saved/{query_id}/,group-search-views/, andworkflows/{workflow_id}/. Also/teams/{organization_id_or_slug}/{team_id_or_slug}/,.../members/, and.../projects/.Follow-ups
A getsentry/sentry-api-schema PR will carry the extension into the published schema and
@sentry/api/operations. A getsentry/toolkit PR will then replace the hand-written scope table with these values. Both will link back here.via @BYK.
--
View Session [Sentry]