CopilotCLIModels queries github.com instead of configured GitHub Enterprise host, causing repeated 401 Bad credentials
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
### Summary
When VS Code is configured to authenticate Copilot against a GitHub Enterprise (`*.ghe.com`) host, the `CopilotCLIModels` component repeatedly fails with `401 Unauthorized: Bad credentials`. It appears to query `github.com` for Copilot user info rather than the configured enterprise host.
### Configuration
```json
"github-enterprise.uri": "https://.ghe.com",
"github.copilot.advanced": {
"authProvider": "github-enterprise"
}
```
### Observed output
The following repeats on every window reload, several times per session:
```
[error] [CopilotCLIModels] Failed to fetch available models: Error: Failed to fetch Copilot user info: 401 Unauthorized: {"message":"Bad credentials"}
```
Notably, in the same log, Copilot authentication against the enterprise host succeeds immediately before and after the failure:
```
[info] ConversationFeature: Waiting for copilot token or BYOK model to activate conversation feature
[error] [CopilotCLIModels] Failed to fetch available models: Error: Failed to fetch Copilot user info: 401 Unauthorized: {"message":"Bad credentials"}
[info] Got Copilot token for
[info] copilot token sku: copilot_for_business_seat_quota
[info] AuthenticationService: firing onDidAuthenticationChange from handleAuthChangeEvent identity change. Has token: true
[error] [CopilotCLIModels] Failed to fetch available models: Error: Failed to fetch Copilot user info: 401 Unauthorized: {"message":"Bad credentials"}
```
So the enterprise token is valid and a business Copilot seat is present, but the CLI models lookup still fails.
### Expected behavior
`CopilotCLIModels` should honor `github.copilot.advanced.authProvider` and `github-enterprise.uri`, and query the configured enterprise host for Copilot user info.
If Copilot CLI integration does not support GitHub Enterprise auth, the feature should be disabled silently for those users rather than logging a recurring error that looks like a broken installation.
### Actual behavior
The component appears to query `github.com` using an enterprise-issued token. Since the user account exists only on the enterprise host and not on `github.com`, the request is rejected with `Bad credentials`.
Chat itself and model selection work correctly. Only the Copilot CLI model list fails, so the practical impact is misleading error noise plus an unavailable CLI model list.
### Steps to reproduce
1. Configure VS Code with `github-enterprise.uri` pointing at a `*.ghe.com` instance.
2. Set `github.copilot.advanced.authProvider` to `github-enterprise`.
3. Sign in with an enterprise account that holds a Copilot business seat and does not exist on `github.com`.
4. Reload the window and open the GitHub Copilot Chat output channel.
### Additional notes
An image upload in the same session also failed with a 401, which may share the same root cause:
```
[warning] Image upload failed, using base64 fallback: Error: Error uploading image: Error: Image upload failed: 401
```
Troubleshooting note for others hitting this: signing in to `github.com` via GitHub CLI does not help, because the enterprise account cannot exist on `github.com`.
### Environment
- VS Code: 1.133.0
- GitHub Copilot Chat: 0.61.0
- OS: Windows
- Auth provider: GitHub Enterprise (`*.ghe.com`)
- Copilot SKU: `copilot_for_business_seat_quota`
Contributor guide
Assessment
This issue has not been assessed yet.