Skip to content

fix(addie): create_github_issue prompts reauth when token has missing scopes#3648

Merged
bokelley merged 1 commit into
mainfrom
bokelley/addie-github-missing-scopes
Apr 30, 2026
Merged

fix(addie): create_github_issue prompts reauth when token has missing scopes#3648
bokelley merged 1 commit into
mainfrom
bokelley/addie-github-missing-scopes

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

create_github_issue was silently calling the GitHub API with a token that didn't have the right scopes — users got a generic "Failed to create issue (403)" fallback instead of the reconnect prompt that would actually fix it.

Root cause

server/src/services/pipes.ts:9 returns { status, accessToken, scopes, missingScopes } for the 'ok' variant. The handler at server/src/addie/mcp/member-tools.ts:5085 only branched on status !== 'ok'missingScopes was unused. When WorkOS Pipes returned { status: 'ok', missingScopes: ['public_repo'] } (e.g., for a user whose OAuth connection predates a scope change), we plowed ahead and let GitHub return 403.

Diagnosis

PostHog $exception events on 2026-04-29 showed two 403s from create_github_issue, ~18 min apart, hitting api.github.com/repos/adcontextprotocol/adcp/issues. 403 (not 401) = token authenticated but lacked permission, which fits the missing-scope hypothesis. (We were unable to attribute these to a user because of the module: unknown bug fixed in #3578 / #3622.)

Fix

When status === 'ok' && missingScopes.length > 0, route the user to the same reconnect path as needs_reauthorization. Also log missingScopes at info so operators can see which scope(s) Pipes is reporting missing.

Test plan

  • New unit test covers the missing-scopes-on-active-token case
  • Existing tests for not_connected, needs_reauthorization, throw-on-getAccessToken, success path, 422 retry, and 500 fallback all still pass (55/55)
  • Pre-commit (test:unit + test-dynamic-imports + typecheck) — green

🤖 Generated with Claude Code

The Pipes getAccessToken call returns { status, accessToken, scopes,
missingScopes } but create_github_issue only branched on status. Users
with a stale OAuth connection that lacked public_repo silently called
the GitHub API and got a 403 fallback ("Failed to create issue (403).
Use draft_github_issue…") instead of the reconnect prompt that would
actually fix it.

Diagnosed from PostHog $exception events on 2026-04-29 — two 403s,
~18min apart, from create_github_issue. Now: when status='ok' but
missingScopes is non-empty, route the user to the same reconnect path
as needs_reauthorization, and log missingScopes at info so operators
can see which scope(s) Pipes is reporting missing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley
bokelley enabled auto-merge (squash) April 30, 2026 10:07
@bokelley
bokelley merged commit d3fe764 into main Apr 30, 2026
14 checks passed
@bokelley
bokelley deleted the bokelley/addie-github-missing-scopes branch April 30, 2026 10:11
bokelley added a commit that referenced this pull request Apr 30, 2026
…3650)

Add JSDoc context next to the level guide in server/src/logger.ts
explaining that logger.error / logger.fatal trigger the #aao-errors
Slack alert and PostHog $exception capture via the pino hook, so they
should be used only for unexpected, page-worthy failures. Expected
failures with a graceful fallback (third-party 4xx, validation, etc.)
should be logger.warn so the alert path is not taken.

Same anti-pattern surfaced as ":rotating_light: System error: unknown"
noise in PRs #3578, #3622, #3648.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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