fix(ci): inject Sentry debug IDs before upload-artifact#21
Closed
FedeZara wants to merge 1 commit into
Closed
Conversation
Sourcemap deobfuscation wasn't resolving for events emitted from the
released bundle. Root cause: getsentry/action-release@v1 (sentry-cli
2.x) uploads as an *artifact bundle*, which Sentry matches against
runtime stack frames using debug IDs — not filename + release-files
fallback. Our bundle had no debug ID, so the matcher had nothing to
match on.
Fix: run `sentry-cli sourcemaps inject` against the built bundle in
the `build` job *before* upload-artifact. Both downstream jobs
download the same artifact:
- sentry-release uploads the injected bundle + sourcemap with the
debug ID embedded in both;
- publish-dist commits the injected JS to dist/<action> — so the
code the consumer actually runs at runtime carries the same
debug ID, and the Sentry SDK reports it in stack frames.
Doing the inject inside sentry-release alone would NOT fix this:
publish-dist downloads its own copy of the (un-injected) artifact,
so runtime bundles would still ship without debug IDs.
Also sets `inject: false` on the sentry-release action explicitly, so
it doesn't re-inject (generating new IDs that wouldn't match what
publish-dist published).
Verified locally: `sentry-cli sourcemaps inject` adds a
`//# debugId=<uuid>` pragma to the JS and a matching `"debugId"`
field to the .map, with the same UUID on both.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Follow-up to PRs #15-#20. Stack frames in Sentry stayed minified despite source-map upload succeeding — fixes the missing piece.
Root cause
getsentry/action-release@v1runs sentry-cli 2.x'ssourcemaps upload, which uploads as an artifact bundle. The Sentry log from the failing release confirms it:Artifact bundles are matched against runtime stack frames via debug IDs — a UUID embedded in both the JS bundle (as
//# debugId=…) and the sourcemap ("debugId": …). The legacy filename + release-files fallback only kicks in when sentry-cli detects no debug IDs and falls back to the older upload path. With sentry-cli 2.x defaulting to artifact bundles, that fallback never triggered, and our bundle had no debug ID, so the matcher had nothing to match on.Verified by inspecting the published bundle on
dist/verify-token://# sourceMappingURL=index.js.mapwas present, but nodebugIdpragma; the sourcemap hadsourcesContentand 942 source entries, butdebugId: <unset>.Fix
Run
sentry-cli sourcemaps injectagainst the built bundle in thebuildjob, before upload-artifact. Both downstream jobs (sentry-release,publish-dist) download the same artifact, so:sentry-releaseuploads the injected bundle + sourcemap to Sentry — debug ID baked in both;publish-distcommits the injected JS todist/<action>— so the bundle consumers actually execute at runtime carries the same debug ID, and the Sentry SDK's stack frames reference it.Verified locally on a fresh build:
The new step also has a sanity check: it greps for the
debugId=pragma in the JS and the"debugId":key in the map, and fails the job if either is missing — so a silent regression in tsup/sentry-cli compatibility wouldn't get past the build job.Why inject in
buildand not insentry-releasegetsentry/action-release@v1acceptsinject: trueand would inject in its own workspace before uploading. But:publish-distruns in parallel-ish — it downloads its own copy ofdist-<action>fromupload-artifact(the pre-inject version) and pushes that todist/<action>.Injecting upstream of
upload-artifactis the only place where one inject covers both consumers of the artifact.inject: falseis set explicitly on the sentry-release step now, so it doesn't re-inject and generate fresh UUIDs that wouldn't match the bundle on the dist branch.Test plan
pnpm typecheckclean,actionlintcleansentry-cli sourcemaps injectagainst a freshpnpm buildof verify-token — confirms inject succeeds, the JS gets a//# debugId=…pragma, and the .map gets a matching"debugId"field with the same UUIDrelease.ymlforverify-tokenwithv0.0.2-test,prerelease=true. Verify in the run log:Inject Sentry debug IDsstep emitsOK: debug IDs injected into verify-token/dist/{index.js,index.js.map}Create Sentry release + upload sourcemapsstep still reportsUpload type: artifact bundlegit show verify-token/v0.0.2-test:dist/index.js | tail -2 | grep debugIdfederico-automations-testsworkflow in failure mode (so the wrapper throws and Sentry receives an event taggedverify-token@v0.0.2-test). In the Sentry UI:getRequiredFernTokeninpackages/shared/src/index.ts), not to minifieddist/index.jsverify-token@v0.0.2-test→ Source Maps tab: should show the artifact bundle with the debug IDOut of scope
verify-token/v0.0.1-testrelease will keep showing minified frames — it was uploaded without a debug ID. Cut a new prerelease (v0.0.2-test) to validate this PR end-to-end. The old release's frames can't be retroactively deobfuscated unless the artifact bundle is re-uploaded with debug IDs, which isn't worth the effort for a smoke-test release.