Skip to content

fix(auth): suggest 'gh auth refresh -s user:email' when token lacks the scope#166

Merged
lanserge merged 1 commit intomainfrom
fix/auth-suggest-user-email-scope
Apr 30, 2026
Merged

fix(auth): suggest 'gh auth refresh -s user:email' when token lacks the scope#166
lanserge merged 1 commit intomainfrom
fix/auth-suggest-user-email-scope

Conversation

@lanserge
Copy link
Copy Markdown
Contributor

Background

When the chipflow API's /auth/github-token endpoint returns 400 with {"error": "missing_email"}, it means the gh CLI's token is missing the user:email scope, so the server can't fetch a verified email and refuses to issue an API key.

The current code just prints the generic "GitHub token authentication failed: ..." message and silently falls through to device flow. In non-interactive contexts that flow then expires after a few minutes, leaving the user with no idea what was wrong or how to fix it.

This was the actual confusion that took ~30 minutes to diagnose during the bundle.zip rollout today. Past chipflow silicon submit invocations had worked fine because that gh token had the scope; a later gh auth refresh (or VS Code re-auth) silently dropped it.

Change

Detect the specific missing_email error code in authenticate_with_github_token and print:

💡 Your `gh` CLI token is missing the `user:email` scope.
   Run this once and retry:
       gh auth refresh -s user:email

Generic-error path unchanged.

Test plan

  • Manual: confirmed today that gh auth refresh -s user:email fixes the situation; this just makes that finding actionable for future users.

When the chipflow API rejects /auth/github-token with
{"error":"missing_email", ...}, it means the gh CLI token is missing
the user:email scope and the server can't fetch a verified email.

Previously the lib just printed the generic "GitHub token authentication
failed: ..." message and silently fell through to device flow (which
then expires in non-interactive contexts). The user had no signal that
their gh token needs a one-line refresh.

Now we detect the specific error code and print:

    💡 Your `gh` CLI token is missing the `user:email` scope.
       Run this once and retry:
           gh auth refresh -s user:email
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 30, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-04-30 06:55 UTC

@github-actions
Copy link
Copy Markdown

Tests Skipped Failures Errors Time
86 10 💤 0 ❌ 0 🔥 34.800s ⏱️

@lanserge lanserge merged commit 151f1e7 into main Apr 30, 2026
6 checks passed
@lanserge lanserge deleted the fix/auth-suggest-user-email-scope branch April 30, 2026 06:54
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