fix: Check OAuth credentials before handler creation for GitHub Copilot#1
Draft
fix: Check OAuth credentials before handler creation for GitHub Copilot#1
Conversation
Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
…tHub Copilot OAuth Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
…uired headers Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
Co-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
--models command listing
… 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>
--models command listingCo-authored-by: Caleb-Lite <175520785+Caleb-Lite@users.noreply.github.com>
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User successfully authenticated with
--github-copilot-loginbut received "No OAuth credentials found" error when using GitHub Copilot models.Root Cause
isApiKeyAvailable()checkedenvVarbeforeoauthFallback. For GitHub Copilot (envVar: "",oauthFallback: "github-oauth.json"), empty string is falsy, causing early returntruewithout verifying OAuth file exists.Changes
isApiKeyAvailable(): CheckoauthFallbackfirst, return false if configured but file missingsrc/,packages/core/src/,packages/cli/src/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).