Repository navigation
fix(cli): Name both orgs when an org auth token targets another org - #2168
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5e11cc3. Configure here.
sentry-junior
Bot
force-pushed
the
fix/cli-scope-challenge-hint
branch
from
November 11, 2026 09:13
0e645c4 to
617827e
Compare
sentry-junior
Bot
force-pushed
the
fix/cli-org-mismatch-hint
branch
from
November 11, 2026 09:13
5e11cc3 to
4e11f86
Compare
sentry-junior
Bot
force-pushed
the
fix/cli-org-mismatch-hint
branch
from
November 11, 2026 09:24
4e11f86 to
3f969ff
Compare
betegon
added a commit
that referenced
this pull request
Nov 11, 2026
Split out of #2160. 401/403s from the CI commands (`release *`, `sourcemap upload`) are silenced as user errors, and the detail on their spans is mostly scrubbed to `[Filtered]`, so we can't tell them apart. Over 14 days that was about 217k failures from about 1.5k orgs. This PR records a fixed reason category for each one. The CLI's own output doesn't change. ### Before ``` # cli.command span api_error.status: 401 api_error.message: Failed to create release: 401 Unauthorized api_error.detail: [Filtered] # cli.error.silenced metric error_class: ApiError reason: api_user_error api_status: 401 # cli.api_error_silenced log status: 401 endpoint: … detail: [Filtered] ``` ### After ``` # cli.command span api_error.status: 401 api_error.message: Failed to create release: 401 Unauthorized api_error.denial_reason: unrecognized # cli.error.silenced metric error_class: ApiError reason: api_user_error api_status: 401 api_denial_reason: unrecognized # cli.api_error_silenced log status: 401 endpoint: … denial_reason: unrecognized ``` The values are `insufficient_scope`, `access_denied`, `expired`, `unrecognized`, `member_policy` and `seat_limit`; #2168 adds `org_mismatch`. On 401/403s, `denial_reason` replaces `detail`. The values avoid words such as "auth" and "token", because scrubbing turns values containing them into `[Filtered]`. <!-- junior-request-attribution:start --> via @betegon. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A28e783cd48c13b214d69caf6d8977a0c --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/agent%3A28e783cd48c13b214d69caf6d8977a0c/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: bete <[email protected]>
…ssing Sentry answers a token that lacks every scope an endpoint accepts with `WWW-Authenticate: Bearer error="insufficient_scope", scope="..."`. Read it and list those scopes, with advice for the credential the request sent: an org:ci hint for personal tokens, "org auth tokens only have org:ci" for org auth tokens, and for a login either `auth login --force` or `auth refresh --scope` with the default scopes kept. Co-Authored-By: bete <[email protected]>
Sentry lists accepted scopes alphabetically, so the first one is often `org:admin` when `org:write` would do, or a scope `auth refresh` rejects, such as `org:billing`. Pick the first accepted scope in SENTRY_SCOPES order (read, write, admin per namespace), and skip the refresh hint when no accepted scope can be requested.
betegon
force-pushed
the
fix/cli-scope-challenge-hint
branch
from
November 11, 2026 10:08
8ad0950 to
84f9ce1
Compare
Keep one table of 403 messages per credential (personal token, org auth token, login) plus the no-challenge fallback. Drop the parser unit tests; the message tests cover the header parsing. Co-Authored-By: bete <[email protected]>
sentry-junior
Bot
force-pushed
the
fix/cli-org-mismatch-hint
branch
from
November 11, 2026 11:28
3f969ff to
9c790b4
Compare
An org auth token only works in its own organization. Sentry answers 403 when the target org is on the same server and 401 "Invalid org token" when it isn't, and neither says why. Compare the `sntrys_` claim of the token the request sent with the org in the request path, and name both orgs when they differ. Numeric org IDs are skipped. Co-Authored-By: bete <[email protected]>
sentry-junior
Bot
force-pushed
the
fix/cli-org-mismatch-hint
branch
from
November 11, 2026 11:28
9c790b4 to
1025dbd
Compare
…hint # Conflicts: # packages/cli/src/lib/api/infrastructure.ts # packages/cli/test/lib/api/infrastructure.test.ts
betegon
approved these changes
Nov 11, 2026
7 tasks done
This branch was previously deployed
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.

Stacked on #2165.
Split out of #2160.
An org auth token works only in its own org. When it targets another org, Sentry answers 403 if both orgs are on the same server, or 401 "Invalid org token" if they aren't, and neither response says why. The CLI now compares the org in the token (
sntrys_…) with the org in the request path and names both orgs when they differ.Before
release createforother-org, with an org auth token formy-orginSENTRY_AUTH_TOKEN:After
These errors are recorded with
denial_reason: org_mismatch(#2163). Numeric org IDs are skipped, and the org comparison ignores case.via @betegon.
--
View Session in Sentry