Skip to content

fix(app): match invalid_mcp_token in cloud MCP auth-failure codes - #2776

Merged
benjaminshafii merged 1 commit into
devfrom
fix/cloud-mcp-auth-code-matching
Jul 15, 2026
Merged

benjaminshafii merged 1 commit into
devfrom
fix/cloud-mcp-auth-code-matching

Conversation

@benjaminshafii

Copy link
Copy Markdown
Member

What

Field incident (Jul 14): a desktop's 7-day first-party MCP token expired and the reconciler's remint-retry never fired — cloud tools 401'd, then vanished from sessions.

Root cause: the Den rejects an expired/missing opaque bearer with code invalid_mcp_token (health prober maps the direct tools/list 401 to this code with alias openwork_cloud_token_expired — apps/server/src/cloud-mcp-health.ts:1434). isCloudMcpAuthTokenFailureCode relied on .includes("invalid_token"), which the _mcp_ infix defeats, and the call site checked .code only, never aliases.

  • Add exact matches for invalid_mcp_token / missing_mcp_token
  • Add isCloudMcpAuthTokenFailure(failure) that also consults aliases and use it at the retry site (repairCloudMcp)

Testing

  • bun test tests/cloud-mcp-health.test.ts in apps/app — 9 pass / 0 fail (2 new tests: expired-token code regression incl. exclusions; alias-driven remint drives the reconciler to a second mint and usable health)
  • pnpm typecheck in apps/app — clean

fraimz: skipped — unit-tested renderer logic, no visual surface change. Part 1/3 of the token-death-spiral fixes (gate fix and maintenance watchdog ship separately).

The Den rejects an expired/missing first-party bearer with code
invalid_mcp_token (alias openwork_cloud_token_expired). The remint-retry
gate used substring checks that the _mcp_ infix defeated, so the retry
built for exactly this failure could never fire — in the field a desktop
token sat expired for ~7 days. Adds exact matches for invalid_mcp_token/
missing_mcp_token and an aliases-aware helper used at the retry site.
@vercel

vercel Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
openwork-app Ready Ready Preview, Comment Jul 15, 2026 2:26am
openwork-den Ready Ready Preview, Comment Jul 15, 2026 2:26am
openwork-den-worker-proxy Ready Ready Preview, Comment Jul 15, 2026 2:26am
openwork-landing Ready Ready Preview, Comment, Open in v0 Jul 15, 2026 2:26am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
openwork-diagnostics Skipped Skipped Jul 15, 2026 2:26am

This branch was successfully deployed

4 active and 1 inactive deployments
Preview – openwork-den-worker-proxy — f4ae2188 Deployed Jul 15, 2026 by vercel[bot]
Preview – openwork-landing — f4ae2188 Deployed Jul 15, 2026 by vercel[bot]
Preview – openwork-den — f4ae2188 Deployed Jul 15, 2026 by vercel[bot]
Preview – openwork-app — f4ae2188 Deployed Jul 15, 2026 by vercel[bot]
Preview – openwork-diagnostics — f4ae2188 Deployed Jul 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant