Skip to content

fix(core): Avoid propagating baggage: "undefined" when DSC is missing#22424

Merged
Lms24 merged 4 commits into
developfrom
lms/fix-browser-avoid-undefined-string-baggage
Jul 21, 2026
Merged

fix(core): Avoid propagating baggage: "undefined" when DSC is missing#22424
Lms24 merged 4 commits into
developfrom
lms/fix-browser-avoid-undefined-string-baggage

Conversation

@Lms24

@Lms24 Lms24 commented Jul 21, 2026

Copy link
Copy Markdown
Member

So, TIL, when you make a fetch request and pass in a headers object where a key could be undefined,

fetch('https://github.com', { headers: { xmyheader: undefined } })

this results in browsers (and possibly node) actually sending baggage: "undefined" over the wire instead of dropping the header. Which is in accordance with the spec (whatwg/fetch#1260) but came as a surprise to me.

I'm fairly sure this isn't a large problem but theoretically, downstream SDKs could interpret this as an incoming invalid baggage header, instead of an incoming request without a baggage header. Not sure if we make this differentiation in practise but I'd rather avoid propagating "undefined" it in the first place.

Background: This came up while testing that our SDK correctly handles the edge case where it receives an incoming sentry-trace but no baggage header (meta tag). In this case, the SDK should assume the upstream SDK is not compatible with dynamic sampling and continue the trace with a frozen, empty DSC (hence not propagate it further).
This is specified in our DSC trace continuation algorithm: https://develop.sentry.dev/sdk/foundations/trace-propagation/dynamic-sampling-context/#unified-propagation-mechanism

@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.

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 48f895c. Configure here.

Comment thread packages/core/src/fetch.ts
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.75 kB - -
@sentry/browser - with treeshaking flags 26.18 kB - -
@sentry/browser (incl. Tracing) 46.58 kB +0.05% +19 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.39 kB +0.03% +14 B 🔺
@sentry/browser (incl. Tracing, Profiling) 51.38 kB +0.04% +17 B 🔺
@sentry/browser (incl. Tracing, Replay) 85.85 kB +0.02% +13 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.48 kB +0.03% +18 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 90.57 kB +0.02% +15 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 103.22 kB +0.02% +11 B 🔺
@sentry/browser (incl. Feedback) 44.93 kB - -
@sentry/browser (incl. sendFeedback) 32.55 kB - -
@sentry/browser (incl. FeedbackAsync) 37.69 kB - -
@sentry/browser (incl. Metrics) 28.83 kB - -
@sentry/browser (incl. Logs) 29.05 kB - -
@sentry/browser (incl. Metrics & Logs) 29.76 kB - -
@sentry/react 29.54 kB - -
@sentry/react (incl. Tracing) 48.86 kB +0.04% +17 B 🔺
@sentry/vue 33.17 kB - -
@sentry/vue (incl. Tracing) 48.54 kB +0.04% +15 B 🔺
@sentry/svelte 27.78 kB - -
CDN Bundle 30.14 kB - -
CDN Bundle (incl. Tracing) 48.55 kB +0.04% +17 B 🔺
CDN Bundle (incl. Logs, Metrics) 31.73 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.85 kB +0.04% +18 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 70.99 kB - -
CDN Bundle (incl. Tracing, Replay) 86.06 kB +0.02% +15 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.37 kB +0.02% +15 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.86 kB +0.02% +14 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 93.14 kB +0.02% +13 B 🔺
CDN Bundle - uncompressed 89.88 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.78 kB +0.04% +51 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.59 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.76 kB +0.04% +51 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.35 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.02 kB +0.02% +51 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.98 kB +0.02% +51 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.72 kB +0.02% +51 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 283.67 kB +0.02% +51 B 🔺
@sentry/nextjs (client) 51.37 kB +0.03% +13 B 🔺
@sentry/sveltekit (client) 47.01 kB +0.05% +19 B 🔺
@sentry/core/server 80.27 kB +0.02% +16 B 🔺
@sentry/core/browser 66.71 kB +0.03% +17 B 🔺
@sentry/node-core 63.21 kB - -
@sentry/node 125.76 kB - -
@sentry/node (incl. diagnostics channel injection) 151.2 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.03 kB -0.01% -2 B 🔽
@sentry/node/light 51.32 kB +0.01% +2 B 🔺
@sentry/node - without tracing 74.92 kB - -
@sentry/aws-serverless 84.15 kB - -
@sentry/cloudflare (withSentry) - minified 197.71 kB +0.03% +51 B 🔺
@sentry/cloudflare (withSentry) 486.7 kB +0.02% +95 B 🔺

View base workflow run

@Lms24
Lms24 marked this pull request as ready for review July 21, 2026 14:02
@Lms24
Lms24 requested a review from a team as a code owner July 21, 2026 14:02
@Lms24
Lms24 requested review from logaretm and msonnb and removed request for a team July 21, 2026 14:02
@Lms24 Lms24 self-assigned this Jul 21, 2026

@msonnb msonnb 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.

'undefined' for undefined is indeed very interesting

@logaretm logaretm 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.

TIL

@Lms24
Lms24 enabled auto-merge (squash) July 21, 2026 14:53
@Lms24
Lms24 merged commit 9f038f9 into develop Jul 21, 2026
614 of 617 checks passed
@Lms24
Lms24 deleted the lms/fix-browser-avoid-undefined-string-baggage branch July 21, 2026 14:54
Lms24 added a commit that referenced this pull request Jul 21, 2026
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.

3 participants