fix: Copilot Business 'token' prefix not overridable by AWF_PLATFORM_TYPE#5872
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a Copilot authentication regression where AWF_PLATFORM_TYPE (auto-injected as ghec on *.ghe.com runners by gh-aw) could incorrectly force Bearer auth, even for Copilot Business/Enterprise catalog endpoints that require the token <oauth> Authorization prefix.
Changes:
- Reorders
copilotTargetRequiresGitHubTokenPrefix()to prioritize catalog endpoint detection (api.business.githubcopilot.com,api.enterprise.githubcopilot.com) ahead of theAWF_PLATFORM_TYPEoverride. - Updates and expands unit tests to cover the full production scenario (Copilot Business target +
*.ghe.com+AWF_PLATFORM_TYPE=ghec) and preserve the intended override behavior for custom/unknown targets. - Adjusts adapter-level tests to match the corrected semantics (catalog endpoints always use
token, custom targets may still be forced toBearervia platform override).
Show a summary per file
| File | Description |
|---|---|
| containers/api-proxy/providers/copilot-auth.js | Fixes auth-prefix decision ordering so catalog endpoints always require token, independent of AWF_PLATFORM_TYPE. |
| containers/api-proxy/copilot-auth.test.js | Corrects prior expectation and adds regression coverage for the GHEC + Business endpoint scenario. |
| containers/api-proxy/copilot-adapter-enterprise.test.js | Aligns adapter behavior tests with the new ordering and adds a #5871 regression test at the adapter level. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Low
|
✅ Copilot review passed with no inline comments. @copilot Add the |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
|
✅ Contribution Check completed successfully! PR #5872 follows the applicable CONTRIBUTING.md guidelines: clear description referencing #5871, tests included for the bug fix, changes are in the appropriate containers/api-proxy files, and no documentation update appears required for this regression fix. |
|
✅ Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓 |
|
Chroot tests failed Smoke Chroot failed - See logs for details. |
|
✅ Build Test Suite completed successfully! |
|
✅ Smoke Gemini completed. All facets verified. 💎 Smoke test complete. GitHub MCP, File Writing, and Bash tools passed. GitHub.com connectivity failed. Overall status: FAIL. |
|
🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅ |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
✅ Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓 |
|
✅ Smoke Claude passed |
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅ |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 FAIL: merged PR checks ✅, file/build ✅, discussion ✅, Playwright unavailable ❌, no PR context for PR comment/label. |
|
✅ Security Guard completed successfully! PR #5872 security review complete: no security-weakening changes detected. Changes only reorder authorization prefix logic to prioritize catalog endpoints (api.business.githubcopilot.com, api.enterprise.githubcopilot.com), making authentication checks MORE restrictive, not less. No firewall, egress, capability, or input validation changes. |
|
✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓 |
|
🔌 Smoke Services — All services reachable! ✅ |
Smoke Test: Claude Engine Validation
Overall Result: PASS ✅ Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
|
Smoke Test: Copilot BYOK (Direct) Mode ✅ GitHub MCP Connectivity Result: PASS — Running in direct BYOK mode with placeholder credentials isolated in agent. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
🔥 Smoke Test Results — Copilot Engine Validation
Overall: PASS
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
🔬 Smoke Test: Copilot PAT Auth — PASS
Overall: PASS · Auth mode: PAT (COPILOT_GITHUB_TOKEN) cc Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test Results
Overall: FAIL — Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
|
Smoke Test: Copilot BYOK (Direct) Mode — Azure OpenAI
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
|
✅ GitHub MCP Testing Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) Overall status: PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
This comment has been minimized.
This comment has been minimized.
Smoke Test: API Proxy OpenTelemetry Tracing
All 5 scenarios passed. OTEL tracing integration is correctly implemented. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: Gemini Engine Validation
Overall Status: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
On
*.ghe.com(GHEC) runners, gh-aw automatically injectsAWF_PLATFORM_TYPE=ghecinto the api-proxy environment. The previous ordering incopilotTargetRequiresGitHubTokenPrefix()checked this guard first, short-circuiting tofalsebefore ever reaching theGITHUB_TOKEN_PREFIX_COPILOT_TARGETScatalog check — causing Copilot Business customers withCOPILOT_API_TARGET=api.business.githubcopilot.comto receiveBearerinstead of the requiredtokenprefix, yielding400 bad request: Authorization header is badly formatted.Changes
containers/api-proxy/providers/copilot-auth.js— ReordercopilotTargetRequiresGitHubTokenPrefix()so catalog endpoints (api.enterprise.githubcopilot.com,api.business.githubcopilot.com) are checked first. These endpoints always requiretokenprefix for GitHub OAuth credentials and must not be overridable byAWF_PLATFORM_TYPE. The platform-type guard is retained but now only affects the GHES heuristic for custom/unknown proxy targets.containers/api-proxy/copilot-auth.test.js— Correct the previously wrong test that expectedfalseforapi.business.githubcopilot.com + AWF_PLATFORM_TYPE=ghec; add regression tests for the full production scenario (Business + GHEC +AWF_PLATFORM_TYPE=ghec).containers/api-proxy/copilot-adapter-enterprise.test.js— Fix adapter test that expectedBearerwhenAWF_PLATFORM_TYPE=github.comwith a GHESGITHUB_SERVER_URLauto-derives the target toapi.enterprise.githubcopilot.com(a catalog endpoint — correctly expectstoken); add a dedicated test preserving the custom-proxy override behavior; add the full GHES 400 bad request: Authorization header is badly formatted #5871 regression integration test.