Skip to content

fix(opencode): resolve GitHub Copilot base URL from token#25995

Closed
massimopalmieri wants to merge 2 commits into
anomalyco:devfrom
massimopalmieri:copilot-baseurl-fix
Closed

fix(opencode): resolve GitHub Copilot base URL from token#25995
massimopalmieri wants to merge 2 commits into
anomalyco:devfrom
massimopalmieri:copilot-baseurl-fix

Conversation

@massimopalmieri
Copy link
Copy Markdown

@massimopalmieri massimopalmieri commented May 6, 2026

Summary

  • resolve the GitHub Copilot API base URL from the Copilot tokens proxy-ep field
  • fall back to the individual Copilot endpoint when the token does not provide a proxy endpoint
  • keep refreshed Copilot auth aligned with the token-derived base URL
  • add tests covering token-derived URL resolution and fallback behavior

Problem

OpenCode used a static GitHub Copilot base URL. In environments where the Copilot token points at a different endpoint, requests should instead follow the endpoint encoded in the token. Pi already handles Copilot this way.

Change

This updates the GitHub Copilot plugin to derive the effective base URL from the Copilot token, using the tokens proxy-ep field when present and a sensible fallback otherwise.

Testing

  • bun run typecheck
  • bun test test/plugin/github-copilot-models.test.ts

Closes #20759

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Hey! Your PR title Fix GitHub Copilot token exchange and dynamic base URL resolution doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found related PRs that address similar Copilot token handling issues:

  1. PR fix(copilot): enable Copilot Business/Enterprise support — bearer exchange, dynamic endpoint, VS Code identity headers #20758 - "fix(copilot): enable Copilot Business/Enterprise support — bearer exchange, dynamic endpoint, VS Code identity headers"

    • Related: Also addresses token exchange and dynamic endpoint resolution for Copilot
  2. PR fix(copilot): add token exchange and editor headers for corporate network compatibility #18782 - "fix(copilot): add token exchange and editor headers for corporate network compatibility"

    • Related: Focuses on token exchange and compatibility headers for Copilot
  3. PR feat(webfetch): add RFC 9728 auth flow and harden OAuth handling #22096 - "feat(webfetch): add RFC 9728 auth flow and harden OAuth handling"

    • Related: Addresses OAuth flow improvements and token handling

These PRs appear to be addressing similar concerns with Copilot token exchange and OAuth flows, though PR #25995 (your current PR) may be a more recent or focused fix. You may want to review whether these older PRs have been merged or superseded, and ensure your implementation doesn't conflict with or duplicate work from PR #20758 and #18782.

@massimopalmieri massimopalmieri changed the title Fix GitHub Copilot token exchange and dynamic base URL resolution fix(opencode): resolve GitHub Copilot base URL from token May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 6, 2026
@github-actions github-actions Bot closed this May 6, 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.

Copilot Business/Enterprise users can't use OpenCode — three compounding auth/endpoint/header issues

1 participant