Skip to content

fix(mcp): Send a new sign-in link when the old attempt is gone - #2932

Merged
dcramer merged 4 commits into
mainfrom
fix/pending-auth-state
Nov 8, 2026
Merged

dcramer merged 4 commits into
mainfrom
fix/pending-auth-state

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

After someone finishes an MCP sign-in in Slack, the resumed Turn still holds its old pending-auth entry. The OAuth callback has already deleted that authorization attempt. If the provider then rejects the new token, Junior tries to reuse the old link, because it is less than 10 minutes old. That lookup fails, so the person gets no new link and the tool call fails.

Now a recent link is reused only while its authorization attempt still exists. Otherwise Junior sends a fresh link.

Tests: tests/integration/slack/mcp-authorization.test.ts runs the Slack path with real wiring. Each test does a mention, sends a private link, approves it through the real OAuth callback route, and resumes the Turn on the queue. The tests assert only what the person sees: two different private links, no answer before the second sign-in, then the answer with no error reply.

  • The provider revokes the grant after sign-in (401 invalid_token, refresh invalid_grant).
  • The provider requires a scope that the first sign-in lacks (403 insufficient_scope), and it issues no refresh token. The new link asks for that scope.

On main, both tests fail: only 1 link is sent, and Junior answers without the tool.

Test abstractions:

  • The Eval Auth fake now models the provider. It stores the grant with its scope, issues a unique token each time, supports refresh, and enforces the required scope. Faults are named provider states with Injected fault: comments (revokeEvalMcpGrant, requireEvalMcpWriteScope, issueNoEvalMcpRefreshTokens). Tests do not count requests.
  • slackApiOutbox.authorizationLinks(user) reads the private sign-in links, so the card layout is in one place.
  • approveMcpAuthorizationLink() is the person approving a link. It follows the provider redirect into the callback route.

The tests pass when shuffled and when run alone. The other tests that use the fake still pass.

Part of #2890 (Pending auth, related to #843).

via @dcramer.

--

View Session [Sentry]

@vercel

vercel Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 8, 2026 7:51pm UTC

Request Review

@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

10 screenshot changes — 10 changed · 0 added · 0 removed

Review screenshots in Frameshift

Conversation Captured Memories Popover · Desktop
Conversation Captured Memories Popover · Desktop
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Details Watched Linked Work · Mobile
Conversation Details Watched Linked Work · Mobile
Changed
Conversation Event Log Virtual · Mobile
Conversation Event Log Virtual · Mobile
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Share Details · Desktop
Conversation Share Details · Desktop
Changed
Show 4 more changed screenshots
Conversation Unsent Answers · Desktop
Conversation Unsent Answers · Desktop
Changed
Conversation Unsent Answers · Mobile
Conversation Unsent Answers · Mobile
Changed
Memories · Mobile
Memories · Mobile
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

sentry-junior Bot and others added 3 commits November 8, 2026 19:12
…sign-in

Fails on main: the resumed Turn reuses the finished sign-in attempt and throws Unknown MCP auth session.
A resumed Turn keeps its pending auth until it delivers. When the provider rejected the new token in that window, Junior reused the finished attempt and failed with Unknown MCP auth session instead of sending a new link. Reuse a link only while its attempt still exists.
Move the scenario to a Slack mention that resumes through the OAuth callback route and worker. Cover a rejected token with an explicit refresh failure and a step-up 403. Give the Eval Auth fake real refresh support so a refresh failure is an injected fault.

Co-Authored-By: David Cramer <[email protected]>
The Eval Auth fake now tracks the person's grant and its scope. Tests inject named provider faults (revoked grant, required scope, no refresh tokens) instead of counting requests. Shared helpers read private authorization links and approve a link through the callback route.

Co-Authored-By: David Cramer <[email protected]>
@dcramer
dcramer merged commit f8d6712 into main Nov 8, 2026
44 checks passed
@dcramer
dcramer deleted the fix/pending-auth-state branch November 8, 2026 23:34

This branch was successfully deployed

1 active deployment
Preview – junior-docs — b8a5058b Deployed Nov 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant