Skip to content

feat(api): Pass each operation's routing declaration to resolveBaseUrl - #131228

Merged
BYK merged 2 commits into
masterfrom
feat/api-route-by-operation
Nov 16, 2026
Merged

BYK merged 2 commits into
masterfrom
feat/api-route-by-operation

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

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 Make @sentry/api configure-once: auth factories, region routing, progressive accuracy #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.

via @BYK.

--

View Session [Sentry]

sentry-junior Bot and others added 2 commits November 16, 2026 12:00
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]>
Generated operations now carry their x-sentry-routing declaration in
their request options, and resolveBaseUrl receives it with the
organization the operation's declared path parameter names. Hosts can
route by Sentry's declarations instead of guessing from path prefixes.

routeCellOperations builds a resolver from a host's existing region
lookup: cell operations go to their organization's region, and control,
both, unknown and raw requests keep the configured base URL. It never
discovers a region itself.

Refs #131198

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested review from a team as code owners November 16, 2026 13:11
@sentry-junior
sentry-junior Bot requested a review from BYK November 16, 2026 13:11
Base automatically changed from feat/api-operation-routing to master November 16, 2026 13:11
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 16, 2026
@BYK
BYK enabled auto-merge (squash) November 16, 2026 13:15
@BYK
BYK merged commit 665b299 into master Nov 16, 2026
73 of 74 checks passed
@BYK
BYK deleted the feat/api-route-by-operation branch November 16, 2026 13:18
BYK added a commit that referenced this pull request Nov 16, 2026
#131228 changed the `@sentry/api` README's routing example to read
`regionUrls`. #131217 merged a minute later with declarations for the
README examples that still define `regionUrlFor`, which no example uses
anymore, so the README example on master references an undeclared name.
This swaps that declaration for `regionUrls: Map<string, string>`.

<!-- 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
…organization (#131245)

Part of #131198. `routeCellOperations` (#131228) keeps raw requests on
the configured base URL, because they carry no routing declaration. The
Sentry CLI's region lookup does more than find a region: it also picks
the stored account, and that account's server, that knows the
organization. So its `sentry api` raw requests need to go through that
lookup to keep reaching an organization whose account is on another
server.

- `routeCellOperations(lookup, { rawRequests: "lookup" })` sends raw
requests whose path names an organization (their `scope`) through
`lookup`. If the lookup returns nothing, they keep the configured base.
- The default, `rawRequests: "baseUrl"`, keeps today's behavior, so
nothing breaks for existing callers.
- Generated operations still follow their declarations either way:
`cell` goes through the lookup, while `control`, `both` and `unknown`
keep the configured base.
- The README documents the option with an example.

<!-- 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]>

This branch was successfully deployed

1 active deployment
Preview — 222bb776 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