fix: restore GITHUB_API_URL in agent container when api-proxy is enabled#1420
Conversation
Root cause: commit 5a56789 excluded GITHUB_API_URL from the agent container when api-proxy is enabled, based on the incorrect theory that its presence would cause the Copilot CLI to route token exchange through api.github.com with the placeholder token. Evidence from CI logs: successful runs (worktree-audit-observability) had GITHUB_API_URL present and worked; all failing runs lacked it and failed immediately with "Authentication failed" after ~1.2 seconds. The Copilot CLI needs GITHUB_API_URL to locate the GitHub API. Its Copilot-specific calls (token exchange, inference) already route through COPILOT_API_URL → api-proxy regardless of GITHUB_API_URL being set. Fix: - Remove EXCLUDED_ENV_VARS.add('GITHUB_API_URL') from api-proxy block - Change conditional GITHUB_API_URL assignment to unconditional - Update test to expect GITHUB_API_URL present even with api-proxy enabled Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/db4a1afe-02b9-43f2-bfae-41febbcbc8b5
There was a problem hiding this comment.
Pull request overview
Restores forwarding of GITHUB_API_URL into the agent container even when --enable-api-proxy is enabled, fixing Copilot CLI authentication regressions caused by removing that env var from the container environment.
Changes:
- Stop excluding
GITHUB_API_URLfrom the agent environment when api-proxy is enabled. - Make
GITHUB_API_URLforwarding unconditional (when set) ingenerateDockerCompose. - Update the unit test expectation so
GITHUB_API_URLis present alongsideCOPILOT_API_URLunder--env-all.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/docker-manager.ts | Ensures GITHUB_API_URL is no longer excluded/conditionally forwarded when api-proxy is enabled. |
| src/docker-manager.test.ts | Updates unit test to expect GITHUB_API_URL to be present with api-proxy + envAll. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // GITHUB_API_URL — always pass when set. The Copilot CLI needs it to locate the GitHub API | ||
| // (especially on GHES/GHEC where the URL differs from api.github.com). | ||
| // Copilot-specific API calls (inference and token exchange) always route through | ||
| // COPILOT_API_URL → api-proxy when api-proxy is enabled, so GITHUB_API_URL does not | ||
| // interfere with credential isolation. | ||
| if (process.env.GITHUB_API_URL) environment.GITHUB_API_URL = process.env.GITHUB_API_URL; |
There was a problem hiding this comment.
This change makes GITHUB_API_URL available in the agent when --enable-api-proxy is on, but the integration test tests/integration/api-proxy.test.ts still asserts the opposite ("should exclude GITHUB_API_URL…"). That test will now fail in CI (Integration Tests workflow runs --testPathPatterns="api-proxy"), so it should be updated/renamed to reflect the new intended behavior (expect GITHUB_API_URL to be present).
Oracle Smoke Verdict🔮 The ancient spirits stir; the firewall omens are read.
Warning
|
Commit 5a56789 incorrectly excluded
GITHUB_API_URLfrom the agent container when--enable-api-proxyis active, causing the Copilot CLI to fail immediately with "Authentication failed". The Copilot CLI needsGITHUB_API_URLto locate the GitHub API; it already routes Copilot-specific calls (token exchange, inference) throughCOPILOT_API_URL → api-proxyregardless.Evidence
Comparing the failing branch against a successful run (
worktree-audit-observability):GITHUB_API_URLin containerChanges
src/docker-manager.ts: RemoveEXCLUDED_ENV_VARS.add('GITHUB_API_URL')from the api-proxy block; make theGITHUB_API_URLforwarding unconditional (matches the working pre-regression behavior):src/docker-manager.test.ts: Flip the expectation —GITHUB_API_URLshould be present even when api-proxy is enabled, alongsideCOPILOT_API_URL.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/github/gh-aw-firewall/actions/jobs/68429069221/usr/bin/gh gh run view 23510263213 --log --job 68429069221(http block)https://api.github.com/repos/github/gh-aw-firewall/actions/runs/23510263213/artifacts/usr/bin/gh gh run download 23510263213 --name agent-artifacts --dir /tmp/agent-artifacts-run(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.