fix(sourcemap): let inject run without authentication - #1526
Merged
Conversation
`sentry sourcemap inject` only rewrites local JS and sourcemap files and never calls the Sentry API, but it has required credentials since getsentry#611 made authentication the default for every command. The opt-out list in that change did not include the sourcemap commands, so `inject` (added a week earlier in getsentry#547) started failing with `AuthError("not_authenticated")` from 0.23.0 onward. `sourcemap resolve`, the other local-only command in the group, already sets `auth: false`. Set `auth: false` on the inject command and add a regression test that runs it with a fresh config dir and no env token. `test/preload.ts` sets a fake `SENTRY_AUTH_TOKEN` for all tests, which is why this went unnoticed.
|
@Gyeonghun-Park is attempting to deploy a commit to the Sentry Team on Vercel. A member of the Team first needs to authorize it. |
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.
Fixes #1525
Problem
sentry sourcemap injectthrowsAuthError("not_authenticated")when no credentials exist, although it only rewrites local JS and.mapfiles and never calls the Sentry API. #611 made authentication the default for everybuildCommandand opted out the commands that work without a token, butsourcemap inject(added in #547 a week earlier) was not on that list, so it has required credentials since 0.23.0.sourcemap resolve, the other local-only command in the group, already setsauth: false.Fix
Set
auth: falseoninjectCommand, with the same commentresolve.tsuses.sourcemap uploadstill requires authentication; no docs or generated files change.Tests
New
test/commands/sourcemap/inject.test.tsruns the command with a fresh config dir and withSENTRY_AUTH_TOKEN,SENTRY_TOKEN, andSENTRY_FORCE_ENV_TOKENcleared, then asserts the JS receives a//# debugId=comment and the map adebugIdfield. It fails onmainwithAuthError: Not authenticated. Run 'sentry auth login' first.and passes with this change. The existing suite did not catch the regression becausetest/preload.tssets a placeholder token for every test.Verified locally (macOS arm64, Node.js 26.8.1, pnpm 10.11.0):
biome checkon the touched files,pnpm typecheck(no generated-file changes), andvitest run test/commands/sourcemap(36 passed). Inpnpm test, 7 tests intest/lib/time-range.test.tsandtest/lib/delta-upgrade.mocked.test.tsfail in this environment on an unmodifiedmainas well (timezone-dependent, local TZ is UTC+9), so they are unrelated. E2E and binary builds were not run.Breaking change
No.
Thank you for reviewing. Happy to move the test next to the existing inject tests in
upload.test.tsor adjust the approach if you prefer.