Skip to content

feat(api): Match a method and concrete path to a catalog operation - #131235

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

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

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

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.

via @BYK.

--

View Session [Sentry]

Add matchOperation to @sentry/api/operations. It finds the catalog
operation for a method and a concrete path, such as
GET /api/0/organizations/acme/issues/, with its decoded path
parameters, so a raw request or proxy can look up its operationId and
routing. A literal segment wins over a parameter at the first segment
where templates differ. createOperationMatcher builds the same matcher
from a filtered catalog or other templates, and throws on first use when
two templates for one method differ only in parameter names.

The operations module is now printed from compiler nodes, so its
generator comes off the string-writer exemption list.

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested review from a team as code owners November 16, 2026 13:41
@sentry-junior
sentry-junior Bot requested a review from BYK November 16, 2026 13:41
@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:43

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f195824. Configure here.

@BYK
BYK merged commit 0159c54 into master Nov 16, 2026
88 checks passed
@BYK
BYK deleted the feat/api-operation-match branch November 16, 2026 13:48
BYK added a commit that referenced this pull request Nov 17, 2026
…1275)

Part of #131203. Follow-up to #131235.

Sentry isn't supported when served under a path prefix, so
`matchOperation` and `createOperationMatcher` in
`@sentry/api/operations` strip `API_BASE_PATH` only at the start of the
path, unlike `parseApiPathScope`. This adds a comment at that check
saying `/sentry/api/0/...` is deliberately not an API path, so the
difference isn't mistaken for a bug, and pins that prefixed paths match
no operation. Matching behavior doesn't change.

<!-- 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 — f195824b 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