Skip to content

feat(api): Add Sentry's routing declarations to the operations catalog - #131222

Merged
BYK merged 1 commit into
masterfrom
feat/api-operation-routing
Nov 16, 2026
Merged

BYK merged 1 commit into
masterfrom
feat/api-operation-routing

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

This is the first slice of #131198. The public schema already declares x-sentry-routing on every operation, but the SDK drops it. This change keeps the declaration on each @sentry/api/operations entry as routing: { silo, organizationParameter? }, so the routing work and its consumers can read it from the shipped catalog. They no longer need path-prefix heuristics.

  • silo is control, cell, both or unknown. It describes declared availability, not a preferred destination. The type docs and README repeat the backend's caveats (see src/sentry/apidocs/README.md).
  • The build fails on an unsupported silo, or on an organizationParameter that isn't in the operation's path. An operation with no declaration gets unknown, the value the backend itself uses when it has none.
  • This is metadata only: request preparation and resolveBaseUrl are unchanged.

The next slice (#131228) feeds this into resolveBaseUrl. It follows the defaults decided in #131198: both uses the client's configured base, unknown and raw requests keep the configured base, and the CLI adopts first.

via @BYK.

--

View Session [Sentry]

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]>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 16, 2026
@BYK
BYK marked this pull request as ready for review November 16, 2026 13:04
@BYK
BYK requested review from a team as code owners November 16, 2026 13:04
@sentry-junior
sentry-junior Bot requested a review from BYK November 16, 2026 13:04
@BYK
BYK merged commit 24a1cf5 into master Nov 16, 2026
90 checks passed
@BYK
BYK deleted the feat/api-operation-routing branch November 16, 2026 13:11
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]>
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

1 active deployment
Preview — 64cbe1fd Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant