Skip to content

Suppress duplicate "Bad credentials" notification after re-authentication#8745

Merged
alexr00 merged 2 commits into
mainfrom
copilot/fix-bad-credentials-error
May 12, 2026
Merged

Suppress duplicate "Bad credentials" notification after re-authentication#8745
alexr00 merged 2 commits into
mainfrom
copilot/fix-bad-credentials-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

Bug Fix

After revoking the OAuth token on github.com and re-signing in via the prompt that VS Code shows, a Bad credentials - https://docs.github.com/rest notification continues to linger, making it look like sign-in failed.

What was the bug?

Two paths react to the same 401 from in-flight API calls:

  1. CategoryTreeNode.doGetChildren shows a vscode.window.showErrorMessage ("Fetching pull requests failed: Bad credentials …") with a "Login again" action.
  2. Since Detect stale GitHub credentials and prompt re-authentication #8728, RateLogger.logApiError invokes CredentialStore.handleAuthError, which centrally drives re-auth via vscode.authentication.getSession({ forceNewSession }).

The central flow completes successfully, but the notification from (1) does not auto-dismiss. macOS native notifications stay on screen long enough that the user sees the stale "Bad credentials" message after they've already finished signing in — on Windows the toast typically dismisses before the browser round-trip completes, hiding the issue.

How did you fix it?

In src/view/treeNodes/categoryNode.ts, when the caught error matches isAuthError (already exported from loggingOctokit.ts), skip the redundant notification and just mark needLogin = true so the tree shows the "Sign in" entry. The centralized handleAuthError remains the single source of truth for the re-auth prompt.

} else if (isAuthError(e)) {
    // Auth errors are handled centrally by CredentialStore.handleAuthError
    // (wired through RateLogger). A duplicate notification here lingers on
    // macOS after re-auth completes, so suppress it.
    needLogin = true;
} else {
    // …existing fallback notification for non-auth errors…
}

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix 'Bad credentials' pop up for GitHub login in VS Code Suppress duplicate "Bad credentials" notification after re-authentication May 12, 2026
Copilot AI requested a review from alexr00 May 12, 2026 15:06
@alexr00 alexr00 marked this pull request as ready for review May 12, 2026 15:28
Copilot AI review requested due to automatic review settings May 12, 2026 15:28
@alexr00 alexr00 enabled auto-merge (squash) May 12, 2026 15:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR suppresses a redundant “Bad credentials” notification in the pull request category tree after a successful re-authentication, relying on the centralized auth-error handling introduced in #8728.

Changes:

  • Detect auth-related API failures via isAuthError in CategoryTreeNode.doGetChildren.
  • Skip the per-call error notification for auth errors and instead set needLogin = true so the tree shows the “Sign in” entry.
Show a summary per file
File Description
src/view/treeNodes/categoryNode.ts Uses isAuthError to avoid showing a duplicate “Bad credentials” toast and marks the tree as needing login.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@alexr00 alexr00 merged commit e8d7ee9 into main May 12, 2026
10 checks passed
@alexr00 alexr00 deleted the copilot/fix-bad-credentials-error branch May 12, 2026 17:40
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.

'Bad credentials' pop up even after I have logged in github via browser

4 participants