Skip to content

fix: Check OAuth credentials before handler creation for GitHub Copilot#1

Draft
Claude wants to merge 11 commits intomainfrom
claude/add-github-copilot-oauth-support
Draft

fix: Check OAuth credentials before handler creation for GitHub Copilot#1
Claude wants to merge 11 commits intomainfrom
claude/add-github-copilot-oauth-support

Conversation

@Claude
Copy link

@Claude Claude AI commented Feb 10, 2026

User successfully authenticated with --github-copilot-login but received "No OAuth credentials found" error when using GitHub Copilot models.

Root Cause

isApiKeyAvailable() checked envVar before oauthFallback. For GitHub Copilot (envVar: "", oauthFallback: "github-oauth.json"), empty string is falsy, causing early return true without verifying OAuth file exists.

Changes

  • Reorder credential checks in isApiKeyAvailable(): Check oauthFallback first, return false if configured but file missing
  • Apply fix to all 3 synced copies: src/, packages/core/src/, packages/cli/src/
function isApiKeyAvailable(info: ApiKeyInfo): boolean {
  // Check OAuth file first
  if (info.oauthFallback) {
    const credPath = join(homedir(), ".claudish", info.oauthFallback);
    return existsSync(credPath);  // Returns false if missing
  }
  
  // Then check envVar for non-OAuth providers
  if (!info.envVar) return true;  // Free tier
  // ...
}

Before: Handler created → credentials loaded → error thrown
After: Credentials checked → handler only created if available

Affects all OAuth-based providers (GitHub Copilot, Gemini Code Assist, Kimi).

Claude AI and others added 2 commits February 10, 2026 02:12
Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Add support for GitHub Copilot OAuth integration feat: Add GitHub Copilot OAuth support via device flow authentication Feb 10, 2026
@Claude Claude AI requested a review from Caleb-Lite February 10, 2026 02:15
…tHub Copilot OAuth

Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
@Claude Claude AI changed the title feat: Add GitHub Copilot OAuth support via device flow authentication docs: Add local testing guide for repository development Feb 10, 2026
…uired headers

Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
@Claude Claude AI changed the title docs: Add local testing guide for repository development Fix GitHub Copilot OAuth token exchange 404 error Feb 10, 2026
Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
@Claude Claude AI changed the title Fix GitHub Copilot OAuth token exchange 404 error feat: Add GitHub Copilot models to --models command listing Feb 10, 2026
Claude AI and others added 2 commits February 10, 2026 02:47
… providers

Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
…elHandler interface

Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
@Claude Claude AI changed the title feat: Add GitHub Copilot models to --models command listing Fix GitHub Copilot handler registration and method signature Feb 10, 2026
Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
@Claude Claude AI changed the title Fix GitHub Copilot handler registration and method signature Fix GitHub Copilot handler registration and interface compliance Feb 10, 2026
@Claude Claude AI changed the title Fix GitHub Copilot handler registration and interface compliance Add GitHub Copilot OAuth support for model access Feb 10, 2026
Claude AI and others added 2 commits February 10, 2026 03:03
…n isApiKeyAvailable

The bug was in isApiKeyAvailable() function - it would return true immediately
when envVar was empty string (like for GitHub Copilot), without checking if the
OAuth credential file exists. This caused the provider resolver to think GitHub
Copilot was available even when no credentials were present.

Fixed by checking oauthFallback FIRST, before the envVar check. This ensures
OAuth-based providers like GitHub Copilot properly validate credentials exist.

Applied to all 3 synced copies: src/, packages/core/src/, packages/cli/src/

Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
Improved the previous fix to properly handle the case where oauthFallback
is configured but the credential file doesn't exist. Now when oauthFallback
is set, the function explicitly returns false if the file is not found,
instead of falling through to check envVar (which could incorrectly return
true for empty string).

This ensures GitHub Copilot and other OAuth providers correctly report as
unavailable when credentials are missing, preventing the confusing error
"No credentials found" after handler creation.

All tests pass:
- GitHub Copilot with OAuth file present: ✅ returns true
- GitHub Copilot without OAuth file: ✅ returns false
- Free tier provider (no OAuth, no envVar): ✅ returns true
- Regular provider with API key: ✅ returns true
- Regular provider without API key: ✅ returns false

Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
@Claude Claude AI changed the title Add GitHub Copilot OAuth support for model access fix: Check OAuth credentials before handler creation for GitHub Copilot Feb 10, 2026
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.

2 participants