Skip to content

feat(core)!: Make tracePropagationTargets matching case-insensitive - #23534

Open
chargome wants to merge 9 commits into
developfrom
charlygomez/js-4-make-tracepropagationtargets-matching-case-insensitive
Open

feat(core)!: Make tracePropagationTargets matching case-insensitive#23534
chargome wants to merge 9 commits into
developfrom
charlygomez/js-4-make-tracepropagationtargets-matching-case-insensitive

Conversation

@chargome

@chargome chargome commented Aug 24, 2026

Copy link
Copy Markdown
Member

String and regex entries in tracePropagationTargets now match the outgoing request URL regardless of casing.

Previously the casing had to match exactly. In browsers the URL is normalized with new URL() first, which lower cases the origin — so 'myApi.com' or /^myApi\.com/ could never match a request to https://myApi.com.

Kept to a dedicated matcher in core instead of changing isMatchingPattern, which also backs ignoreErrors, denyUrls and ignoreTransactions.

Also drops the g/y flags on target regexes — they make test() stateful, so /myApi\.com/g previously matched only every other request.

Fixes #16018

String and regex entries in `tracePropagationTargets` now match the outgoing
request URL regardless of casing.

Previously the casing had to match exactly. In browsers the URL is normalized
with `new URL()` first, which lower-cases the origin, so `'myApi.com'` or
`/^myApi\.com/` could never match a request to `https://myApi.com`.

Keep this to a dedicated matcher in core instead of changing `isMatchingPattern`,
which also backs `ignoreErrors`, `denyUrls` and `ignoreTransactions`.

Also drop the `g`/`y` flags on target regexes, which make `test()` stateful, so
`/myApi\.com/g` previously matched only every other request.

Fixes #16018
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chargome chargome self-assigned this Aug 24, 2026
@linear-code

linear-code Bot commented Aug 24, 2026

Copy link
Copy Markdown

JS-4

Note the new behaviour in the `tracePropagationTargets` JSDoc that users see in
their editor, and scope the migration guide example to browsers. Server SDKs match
against the raw URL, so a target matching the request's casing did work there in v10.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Comment thread packages/browser/test/tracing/request.test.ts Fixed
Comment thread packages/browser/test/tracing/request.test.ts Fixed
Comment thread packages/browser/test/tracing/request.test.ts Fixed
Comment thread packages/browser/test/tracing/request.test.ts Fixed
Comment thread packages/core/test/lib/utils/tracePropagationTargets.test.ts Fixed
Comment thread packages/core/test/lib/utils/tracePropagationTargets.test.ts Fixed
Comment thread packages/core/test/lib/utils/tracePropagationTargets.test.ts Fixed
Comment thread packages/core/test/lib/utils/tracePropagationTargets.test.ts Fixed
Comment thread packages/core/test/lib/utils/tracePropagationTargets.test.ts Fixed
Comment thread packages/core/test/lib/utils/tracePropagationTargets.test.ts Fixed
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.57 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.47 kB +0.27% +128 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.5 kB +0.29% +138 B 🔺
@sentry/browser (incl. Tracing, Profiling) 51.39 kB +0.27% +134 B 🔺
@sentry/browser (incl. Tracing, Replay) 87.86 kB +0.14% +120 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.32 kB +0.15% +115 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 92.55 kB +0.12% +104 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 105.26 kB +0.13% +134 B 🔺
@sentry/browser (incl. Feedback) 45.81 kB - -
@sentry/browser (incl. sendFeedback) 33.36 kB - -
@sentry/browser (incl. FeedbackAsync) 38.47 kB - -
@sentry/browser (incl. Metrics) 29.52 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.45 kB - -
@sentry/react 30.33 kB - -
@sentry/react (incl. Tracing) 50.68 kB +0.32% +158 B 🔺
@sentry/vue 35.4 kB - -
@sentry/vue (incl. Tracing) 50.47 kB +0.31% +152 B 🔺
@sentry/svelte 28.6 kB - -
CDN Bundle 30.32 kB - -
CDN Bundle (incl. Tracing) 48.99 kB +0.25% +120 B 🔺
CDN Bundle (incl. Logs, Metrics) 32.54 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.86 kB +0.25% +125 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 72.91 kB - -
CDN Bundle (incl. Tracing, Replay) 86.45 kB +0.14% +118 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.32 kB +0.19% +161 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 92.19 kB +0.14% +125 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.13 kB +0.15% +132 B 🔺
CDN Bundle - uncompressed 89.94 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.51 kB +0.27% +388 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.23 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.2 kB +0.26% +388 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.18 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.79 kB +0.15% +395 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.47 kB +0.15% +395 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.49 kB +0.15% +395 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.15 kB +0.14% +395 B 🔺
@sentry/nextjs (client) 53.2 kB +0.25% +130 B 🔺
@sentry/sveltekit (client) 48.89 kB +0.29% +139 B 🔺
@sentry/core/server 65.11 kB +0.25% +158 B 🔺
@sentry/core/browser 52.27 kB +0.32% +162 B 🔺
@sentry/node 117.6 kB +0.12% +135 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.18 kB - -
@sentry/node - without tracing 82.15 kB +0.18% +144 B 🔺
@sentry/aws-serverless 91.58 kB +0.16% +144 B 🔺
@sentry/cloudflare (withSentry) - minified 195.28 kB +0.31% +599 B 🔺
@sentry/cloudflare (withSentry) 482.84 kB +0.33% +1.54 kB 🔺

View base workflow run

…s` tests

CodeQL's js/incomplete-hostname-regexp flagged 16 new high-severity alerts on the
test fixtures added in this branch: patterns like `/^https:\/\/myapi\.com/` and
`'myapi.com'` also match `https://myapi.com.evil.com`.

The rule is right to flag these. `tracePropagationTargets` decides which outgoing
requests receive `sentry-trace` and `baggage` headers, so an unterminated target
leaks trace context to unintended hosts, and these fixtures are what users copy.

Terminate the host portion of each fixture. The assertions cover casing, not
anchoring, so this does not weaken them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Comment thread packages/core/test/lib/utils/tracePropagationTargets.test.ts Fixed
chargome and others added 3 commits August 24, 2026 16:09
The `g`-flag regression test still used a pattern with no leading anchor, which
CodeQL flagged because arbitrary hosts can precede it.

Anchoring it keeps the test's purpose intact: with `g` preserved the anchored
pattern still fails the second call, because `test()` resumes from `lastIndex`
where `^` can no longer match. Verified by reverting the flag-stripping, which
fails this test alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ake-tracepropagationtargets-matching-case-insensitive
@chargome

chargome commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

bughansl run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e768fb2. Configure here.

chargome and others added 3 commits August 25, 2026 09:46
…lifecycle

The new suites were copied from neighbouring ones that pin `traceLifecycle: 'static'`,
so they covered the non-default path. Span streaming is the default in v11, which is
what these should exercise.

The node envelope assertion moves from `transaction` to `span`, since streaming emits
span v2 items rather than transaction events. Both suites were re-confirmed to fail
without the fix under streaming.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…case-insensitive' of https://github.com/getsentry/sentry-javascript into charlygomez/js-4-make-tracepropagationtargets-matching-case-insensitive
@chargome
chargome marked this pull request as ready for review August 25, 2026 08:37
@chargome
chargome requested review from a team as code owners August 25, 2026 08:37
@chargome
chargome requested review from JPeer264, andreiborza, isaacs, logaretm, msonnb and nicohrubec and removed request for a team August 25, 2026 08:37

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgTM/i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make tracePropagationTargets matching case-insensitive

3 participants