Skip to content

fix(inject): Skip non-base64 embedded sourcemaps#3243

Merged
loewenheim merged 3 commits intogetsentry:masterfrom
nyan-left:fix/false-positive-embedded-sourcemap
Mar 26, 2026
Merged

fix(inject): Skip non-base64 embedded sourcemaps#3243
loewenheim merged 3 commits intogetsentry:masterfrom
nyan-left:fix/false-positive-embedded-sourcemap

Conversation

@nyan-left
Copy link
Copy Markdown
Contributor

@nyan-left nyan-left commented Mar 25, 2026

Description

When you bundle tools like terser or babel into a single JS file (common in browser-based IDEs or bundler workers), their minified code contains template literals that build //# sourceMappingURL=data:application/json;base64,... strings as output. After minification, these can land at the start of a line, and discover_sourcemaps_location treats them as real sourcemap directives.

The problem is the "base64" payload is actually just more JS code, so decoding fails and sourcemaps inject bails with Invalid embedded sourcemap, stopping the whole injection.

This changes the bail! to a warn! + continue, which matches how the injection flow already handles other non-fatal cases like missing sourcemaps, ambiguous paths, and unfound files. The file gets skipped and everything else processes normally.

Includes a test with a minimal fixture that reproduces the issue.

Issues

#3244

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@nyan-left nyan-left requested review from a team and szokeasaurusrex as code owners March 25, 2026 12:11
@nyan-left nyan-left changed the title Fix/false positive embedded sourcemap fix: false positive embedded sourcemap Mar 25, 2026
@dingsdax dingsdax requested a review from loewenheim March 26, 2026 09:01
Copy link
Copy Markdown
Contributor

@loewenheim loewenheim left a comment

Choose a reason for hiding this comment

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

Very nice, thank you for the fix!

@loewenheim loewenheim changed the title fix: false positive embedded sourcemap fix(inject): Skip non-base64 embedded sourcemaps Mar 26, 2026
@loewenheim
Copy link
Copy Markdown
Contributor

I took the liberty of adding a changelog entry.

@nyan-left
Copy link
Copy Markdown
Contributor Author

Thanks @loewenheim ! :)

@loewenheim loewenheim merged commit 1d1b9d9 into getsentry:master Mar 26, 2026
24 of 25 checks passed
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.

2 participants