Repository navigation
feat(api): Add Sentry's routing declarations to the operations catalog - #131222
Merged
Merged
Conversation
Copy each operation's x-sentry-routing declaration into
@sentry/api/operations as routing: {silo, organizationParameter?}, and
reject an unsupported silo or an organization parameter that is not in
the path. This is metadata only; request routing does not change.
Refs #131198
Co-Authored-By: BYK <[email protected]>
BYK
approved these changes
Nov 16, 2026
BYK
approved these changes
Nov 16, 2026
BYK
added a commit
that referenced
this pull request
Nov 16, 2026
#131228) This is the second slice of #131198, stacked on #131222. Generated operations now carry their `x-sentry-routing` declaration in their request options. `resolveBaseUrl` receives it as `routing`, plus `organization`, the value of the path parameter the declaration names. Hosts can route by what Sentry declares instead of guessing from path prefixes. - `routeCellOperations(lookup)` in `@sentry/api/client` applies the defaults decided in #131198. `cell` operations go to the region the host's lookup returns for their organization. `control`, `both` and `unknown` operations, raw requests, and organizations the lookup doesn't know keep the configured base URL. It never discovers a region, and the host keeps its own locality cache. - `scope` is still passed, so existing resolvers keep working. - Bound methods, standalone functions and `prepareRequest` all share one resolution per request. - Open question: a resolver can't tell a per-call `baseUrl` apart from the configured one. Callers that need a fixed host can pass a per-call `resolveBaseUrl`, as they can today. The CLI adopts it next, with its existing region resolver and SQLite cache. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A69da19b385017e68b7f9eace56e9477f --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A69da19b385017e68b7f9eace56e9477f) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A69da19b385017e68b7f9eace56e9477f/?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]>
2 tasks done
BYK
added a commit
that referenced
this pull request
Nov 16, 2026
…131235) Part of #131203. Adds `matchOperation(method, path)` to `@sentry/api/operations`. Given a concrete request, such as `GET /api/0/organizations/acme/issues/`, it returns the catalog operation (`operationId`, template, and `routing` from #131222) and the decoded path parameters. A raw-request layer, proxy or cache can then tell which operation it is handling without writing its own path rules. - The matcher is a segment tree built from the catalog templates and indexed on first call, so importing the entry does no work. - The path may include `API_BASE_PATH`, an origin or a query string. A missing trailing slash still matches. - Where templates overlap, a literal segment wins over a parameter at the first segment where they differ. For example, `/preprodartifacts/snapshots/latest-base/` wins over `/preprodartifacts/snapshots/{snapshot_id}/`. If the literal branch has no match for the method, the matcher falls back to the parameter. - Two templates for one method that differ only in parameter names can't be ordered, so the matcher throws on first use. The shipped catalog has none. - `createOperationMatcher` builds the same matcher from any `{ method, path }` list, such as a filtered catalog or a consumer's own templates. The shipped catalog only covers public operations. The operations module is now printed from `ts.factory` nodes, like the docs module, so `generate-operations.mjs` comes off the string-writer exemption list. The emitted catalog is the same array literal. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A9cddb8264df48e793bc61c15cd431e51 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A9cddb8264df48e793bc61c15cd431e51) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A9cddb8264df48e793bc61c15cd431e51/?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]>
This branch was successfully deployed
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.
This is the first slice of #131198. The public schema already declares
x-sentry-routingon every operation, but the SDK drops it. This change keeps the declaration on each@sentry/api/operationsentry asrouting: { silo, organizationParameter? }, so the routing work and its consumers can read it from the shipped catalog. They no longer need path-prefix heuristics.siloiscontrol,cell,bothorunknown. It describes declared availability, not a preferred destination. The type docs and README repeat the backend's caveats (seesrc/sentry/apidocs/README.md).silo, or on anorganizationParameterthat isn't in the operation's path. An operation with no declaration getsunknown, the value the backend itself uses when it has none.resolveBaseUrlare unchanged.The next slice (#131228) feeds this into
resolveBaseUrl. It follows the defaults decided in #131198:bothuses the client's configured base,unknownand raw requests keep the configured base, and the CLI adopts first.via @BYK.
--
View Session [Sentry]