Repository navigation
feat(cli): Send login_hint with sentry auth login <email> - #1580
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pass the requested email as the device flow's login_hint so Sentry refuses approval from a different signed-in user up front, instead of the CLI discarding the token after the fact. The local email check stays for servers that ignore the hint. Server side: getsentry/sentry#128458 Co-Authored-By: BYK <[email protected]>
sentry-junior
Bot
force-pushed
the
feat/cli-device-login-hint
branch
from
October 27, 2026 21:44
d17f1be to
e630c99
Compare
BYK
added a commit
to getsentry/sentry
that referenced
this pull request
Oct 28, 2026
…8458) The Sentry CLI's `sentry auth login <email>` (getsentry/toolkit multi-account mode) has no way to tell the device flow which account it expects. Whoever is signed in to the browser approves the request, and the CLI can only throw the token away afterwards. By then the server has already issued it. This PR adds an optional `login_hint` to `POST /oauth/device/code/`. RFC 8628 §3.1 allows extension parameters, and the name comes from OpenID Connect. The hint is an email. It is stored on `ApiDeviceCode` and checked on the verification endpoint: - `GET /api/0/oauth/device/` (consent preparation) returns 403 if the signed-in user's primary email doesn't match the hint, case-insensitively. Consent is not bound to the session. The `detail` names the expected account. - `POST /api/0/oauth/device/` checks again before approving or denying, so a prepared session can't get around it. Without a hint, everything works as before. **Why 403 and the primary email** - The device page already treats a 403 on consent from an authenticated session as "this account can't authorize the request." It shows the error and keeps the switch-account control. So the user sees "This request is for [email protected]. Sign in as that account to continue." with no frontend change needed. - The CLI checks `user.email` from the token response. Matching only the primary email keeps the server and the CLI in agreement. **Notes for review** - Migration `1245` adds a nullable `varchar(200)` column to `sentry_apidevicecode`. The length matches `User.email`. A hint over 200 characters gets `invalid_request`. - The hint is sanitized with `set_email` during relocation, and the exhaustive backup fixture now sets it. - The hint is not logged. Only a `has_login_hint` metric tag is added. The CLI side is getsentry/toolkit#1580. Fixes #127918 Fixes ENG-8835 <!-- junior-request-attribution:start --> via **BYK**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:local%3Aweb%3A7f8efa11623b9416987ceb44 --> -- [View Junior Session in Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A7f8efa11623b9416987ceb44/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
BYK
approved these changes
Nov 9, 2026
BYK
enabled auto-merge (squash)
November 9, 2026 12:23
Resolve the conflict in packages/cli/src/lib/oauth.ts: keep main's requestDeviceCode (no withHttpSpan wrapper) and re-apply the loginHint parameter passed to deviceCodeRequestBody. Co-Authored-By: BYK <[email protected]>
joshuawayzwright
pushed a commit
to joshuawayzwright/sentry-mcp
that referenced
this pull request
Nov 16, 2026
…, url-parser) (getsentry#1580) ## Summary Fix 3 grandfathered silent catch blocks by adding `log.debug()` calls to surface errors that were previously swallowed silently. Each fix follows the project's established pattern from AGENTS.md and the `no-silent-catch` Biome plugin (getsentry#1531). ## Changes ### 1. `src/lib/resolve-team.ts` — `fetchOrgListHint()` **Root cause:** When `listOrganizations()` fails during team resolution (used by `project create` and `init`), the error was silently swallowed. Users got a generic fallback hint with no indication of what went wrong (expired token, network issue, 403, etc.). **Reproduction:** Any scenario where `listOrganizations()` fails during team resolution — e.g., run `sentry project create` with an expired token. **Fix:** Add `log.debug("Failed to fetch org list for hint", error)` and remove the `biome-ignore` comment. ### 2. `src/lib/trace-target.ts` — `recoveryContextFromTargetArg()` **Root cause:** When `parseOrgProjectArg` threw on a malformed target string during trace ID recovery, the error was silently swallowed and recovery proceeded with empty context. This hid parse errors that could help debug user input issues in `trace view`, `span view`, `span list`. **Reproduction:** Run `sentry trace view --h/nothex` — the slug validation error from `parseOrgProjectArg` is silently swallowed. **Fix:** Add `log.debug("Failed to parse target arg for recovery context", error)`, promote the logger to module scope, and rename the shadowed local in `warnIfNormalized` to fix the `noShadow` lint error. ### 3. `src/lib/sentry-url-parser.ts` — `parseSentryUrl()` **Root cause:** When a URL-looking string (starts with `http://` or `https://`) failed to parse via `new URL()`, the error was silently swallowed. This function is used by dashboard, event, trace, and other commands to detect pasted Sentry URLs. **Reproduction:** Pass a malformed URL like `https://[invalid` to any command that accepts Sentry URLs. **Fix:** Add `log.debug("Failed to parse URL", input, error)` and remove the `biome-ignore` comment. ## Testing - All existing tests pass (resolve-team: 1 test, trace-target: 19 tests, sentry-url-parser: 84 tests) - Lint passes clean (`biome check` — 0 errors) <div><a href="https://cursor.com/agents/bc-259f34b1-c9e3-4d43-a65c-4138f0f6d5ca?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/automations/95624600-485e-4461-829e-6b76f086c473"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/view-automation-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/view-automation-light.png"><img alt="View Automation" width="141" height="28" src="https://cursor.com/assets/images/view-automation-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: Miguel Betegón <[email protected]>
joshuawayzwright
pushed a commit
to joshuawayzwright/sentry-mcp
that referenced
this pull request
Nov 16, 2026
…, url-parser) (getsentry#1580) ## Summary Fix 3 grandfathered silent catch blocks by adding `log.debug()` calls to surface errors that were previously swallowed silently. Each fix follows the project's established pattern from AGENTS.md and the `no-silent-catch` Biome plugin (getsentry#1531). ## Changes ### 1. `src/lib/resolve-team.ts` — `fetchOrgListHint()` **Root cause:** When `listOrganizations()` fails during team resolution (used by `project create` and `init`), the error was silently swallowed. Users got a generic fallback hint with no indication of what went wrong (expired token, network issue, 403, etc.). **Reproduction:** Any scenario where `listOrganizations()` fails during team resolution — e.g., run `sentry project create` with an expired token. **Fix:** Add `log.debug("Failed to fetch org list for hint", error)` and remove the `biome-ignore` comment. ### 2. `src/lib/trace-target.ts` — `recoveryContextFromTargetArg()` **Root cause:** When `parseOrgProjectArg` threw on a malformed target string during trace ID recovery, the error was silently swallowed and recovery proceeded with empty context. This hid parse errors that could help debug user input issues in `trace view`, `span view`, `span list`. **Reproduction:** Run `sentry trace view --h/nothex` — the slug validation error from `parseOrgProjectArg` is silently swallowed. **Fix:** Add `log.debug("Failed to parse target arg for recovery context", error)`, promote the logger to module scope, and rename the shadowed local in `warnIfNormalized` to fix the `noShadow` lint error. ### 3. `src/lib/sentry-url-parser.ts` — `parseSentryUrl()` **Root cause:** When a URL-looking string (starts with `http://` or `https://`) failed to parse via `new URL()`, the error was silently swallowed. This function is used by dashboard, event, trace, and other commands to detect pasted Sentry URLs. **Reproduction:** Pass a malformed URL like `https://[invalid` to any command that accepts Sentry URLs. **Fix:** Add `log.debug("Failed to parse URL", input, error)` and remove the `biome-ignore` comment. ## Testing - All existing tests pass (resolve-team: 1 test, trace-target: 19 tests, sentry-url-parser: 84 tests) - Lint passes clean (`biome check` — 0 errors) <div><a href="https://cursor.com/agents/bc-259f34b1-c9e3-4d43-a65c-4138f0f6d5ca?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/automations/95624600-485e-4461-829e-6b76f086c473"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/view-automation-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/view-automation-light.png"><img alt="View Automation" width="141" height="28" src="https://cursor.com/assets/images/view-automation-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: Miguel Betegón <[email protected]>
joshuawayzwright
pushed a commit
to joshuawayzwright/sentry-mcp
that referenced
this pull request
Nov 16, 2026
…, url-parser) (getsentry#1580) ## Summary Fix 3 grandfathered silent catch blocks by adding `log.debug()` calls to surface errors that were previously swallowed silently. Each fix follows the project's established pattern from AGENTS.md and the `no-silent-catch` Biome plugin (getsentry#1531). ## Changes ### 1. `src/lib/resolve-team.ts` — `fetchOrgListHint()` **Root cause:** When `listOrganizations()` fails during team resolution (used by `project create` and `init`), the error was silently swallowed. Users got a generic fallback hint with no indication of what went wrong (expired token, network issue, 403, etc.). **Reproduction:** Any scenario where `listOrganizations()` fails during team resolution — e.g., run `sentry project create` with an expired token. **Fix:** Add `log.debug("Failed to fetch org list for hint", error)` and remove the `biome-ignore` comment. ### 2. `src/lib/trace-target.ts` — `recoveryContextFromTargetArg()` **Root cause:** When `parseOrgProjectArg` threw on a malformed target string during trace ID recovery, the error was silently swallowed and recovery proceeded with empty context. This hid parse errors that could help debug user input issues in `trace view`, `span view`, `span list`. **Reproduction:** Run `sentry trace view --h/nothex` — the slug validation error from `parseOrgProjectArg` is silently swallowed. **Fix:** Add `log.debug("Failed to parse target arg for recovery context", error)`, promote the logger to module scope, and rename the shadowed local in `warnIfNormalized` to fix the `noShadow` lint error. ### 3. `src/lib/sentry-url-parser.ts` — `parseSentryUrl()` **Root cause:** When a URL-looking string (starts with `http://` or `https://`) failed to parse via `new URL()`, the error was silently swallowed. This function is used by dashboard, event, trace, and other commands to detect pasted Sentry URLs. **Reproduction:** Pass a malformed URL like `https://[invalid` to any command that accepts Sentry URLs. **Fix:** Add `log.debug("Failed to parse URL", input, error)` and remove the `biome-ignore` comment. ## Testing - All existing tests pass (resolve-team: 1 test, trace-target: 19 tests, sentry-url-parser: 84 tests) - Lint passes clean (`biome check` — 0 errors) <div><a href="https://cursor.com/agents/bc-259f34b1-c9e3-4d43-a65c-4138f0f6d5ca?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/automations/95624600-485e-4461-829e-6b76f086c473"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/view-automation-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/view-automation-light.png"><img alt="View Automation" width="141" height="28" src="https://cursor.com/assets/images/view-automation-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: Miguel Betegón <[email protected]>
7 tasks done
This branch was successfully 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.
sentry auth login <email>now sends the email aslogin_hintin the device authorization request. Sentry adds support for this in getsentry/sentry#128458. With it, the verification page refuses approval from a different signed-in user up front and asks them to switch accounts. Today the user approves, and only then does the CLI throw the token away.deviceCodeRequestBody(toolkit-core) takes an optionalloginHintand addslogin_hintonly when one is given. Callers that don't pass it, such as the MCP stdio flow, send the same body as before.performDeviceFlow/requestDeviceCodepass the hint through.runInteractiveLoginsendsexpectedEmail.assertExpectedLoginEmailcheck stays. Servers that predate the parameter ignore it, including self-hosted instances and sentry.io until #128458 deploys. On those, the browser's user can still approve, and the CLI-side check is what catches a mismatch.auth loginhelp text and theauthdocs fragment are updated to match.Re-authorizing a stored account by
accountId(scope recovery) doesn't send a hint. That check matches by user id, and the stored email could be stale.Checks run locally
vitestpasses fortest/lib/interactive-login.test.ts,test/lib/oauth.test.ts,test/commands/auth/*andtoolkit-core/src/oauth-device.test.ts.pnpm run lintpasses.tsc --noEmitis clean for toolkit-core and mcp-server. In the CLI, the only errors are missing generated files.typecheckscript couldn't finish here becausegenerate:bannercrashes in this sandbox's Node 22.22.2 (the pin is 22.23.4). CI should cover it.via BYK.
--
View Junior Session in Sentry