Skip to content

fix(core): reject GitHub Copilot login without chat entitlement - #46959

Open
rekram1-node wants to merge 1 commit into
v2from
copilot-entitlement
Open

fix(core): reject GitHub Copilot login without chat entitlement#46959
rekram1-node wants to merge 1 commit into
v2from
copilot-entitlement

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Fixes #46891

Problem

GitHub device OAuth succeeds for any GitHub account, including ones with no Copilot subscription or organization seat. The plugin persisted the credential regardless, so Integrations showed GitHub Copilot as connected while /models returned an empty list and there was no explanation.

Change

The plugin already calls GET /copilot_internal/user after the device flow, but only read endpoints.api. This is the same endpoint VS Code uses as its Copilot entitlement gate (chat_enabled in defaultAccount.ts / chatEntitlementService.ts).

  • Decode chat_enabled and can_signup_for_limited from that response.
  • If the account reports chat_enabled: false, fail the OAuth attempt instead of persisting the credential. The failure message is surfaced through the existing attempt error path:
    • eligible for Copilot Free (can_signup_for_limited: true): tells the user to sign up and reconnect.
    • otherwise: tells the user the account needs an active subscription or an org-assigned seat.
  • A failed or malformed lookup (network error, 5xx, 401/404) keeps the previous tolerant behavior and still persists the credential, so a GitHub API hiccup cannot block login. Only an explicit denial blocks.

Existing connections made before this change are not affected; disconnecting and reconnecting hits the new check.

Testing

  • Added unit tests for copilotEntitlementError covering both denial messages and the tolerant path.
  • bun test test/plugin/provider-github-copilot.test.ts and bun typecheck pass in packages/core.

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