Repository navigation
Description
Describe the bug
When using @github/copilot-sdk v0.3.0 (CLI v1.0.36) in headless mode behind a corporate HTTP proxy, session.create fails with "fetch failed". The CLI subprocess receives all proxy env vars correctly, and standalone undici 7.22 can reach api.github.com through the same proxy from the same container — but the CLI's internal fetch ignores the proxy.
This is a regression from CLI v0.0.394 where the same setup worked.
Key evidence
-
Standalone undici works — from inside the Docker container:
undici version: 7.22.0 Status: 200 Body: {"login":"...", "copilot_plan":"copilot_for_business"...} -
curl works — through the same proxy:
curl -x http://proxy:443 https://api.github.com/copilot_internal/user → 200 -
CLI subprocess gets proxy env — confirmed by intercepting
child_process.spawn:SPAWN command: node /app/node_modules/@github/copilot/index.js --headless --no-auto-update SPAWN HTTPS_PROXY: http://proxy:443 SPAWN HTTP_PROXY: http://proxy:443 SPAWN NODE_TLS_REJECT_UNAUTHORIZED: 0 SPAWN env: COPILOT_SDK_AUTH_TOKEN = gho_xxx... -
CLI fails anyway:
FAILED: Request session.create failed with message: fetch failed -
No TLS MITM — the proxy does transparent CONNECT (real
*.github.comcert from Sectigo, not a proxy-injected cert):subject=CN = *.github.com issuer=C = GB, O = Sectigo Limited, CN = Sectigo Public Server Authentication CA DV E36 -
NODE_EXTRA_CA_CERTS doesn't help — tested with the full cert chain, same result
Version comparison
| Component | Working | Broken |
|---|---|---|
@github/copilot-sdk |
0.1.19 | 0.3.0 |
@github/copilot CLI |
0.0.394 | 1.0.36 |
| Node.js | v22.22.0 | v22.22.0 |
| Result | Sessions work | "fetch failed" |
Affected version
GitHub Copilot CLI 1.0.36
Steps to reproduce the behavior
- Run in a Docker container with
HTTPS_PROXYset to a corporate HTTP CONNECT proxy - Install
@github/[email protected]+@github/[email protected] - Create a CopilotClient with
gitHubTokenand start it:const { CopilotClient } = require("@github/copilot-sdk"); const client = new CopilotClient({ gitHubToken: token, useLoggedInUser: false }); await client.start();
- Call
createSessionwithgitHubToken:const session = await client.createSession({ model: "gpt-4o", gitHubToken: token, streaming: false, systemMessage: { content: "Be brief." }, onPermissionRequest: () => ({ result: "allow" }), });
- Observe:
Request session.create failed with message: fetch failed
Expected behavior
session.create should respect HTTPS_PROXY / HTTP_PROXY environment variables for its internal auth fetch to api.github.com, the same way standalone undici 7.22 does from the same container.
Additional context
- Environment: Docker (
node:22-alpine), Linux x86_64 - Proxy: Corporate HTTP CONNECT proxy on port 443, no TLS interception
- Use case: Server-side SDK integration for automated coding agent (not interactive CLI)
- The specific failing path in CLI:
resolveSessionAuth()→ internal token validation fetch toapi.github.com/copilot_internal/user— this fetch does not go through the proxy - Startup auth also fails silently:
client.start()→trySdkTokenLogin()→ same fetch failure, but caught silently. CLI boots with no auth. The session-level auth then fails loudly. - BYOK provider works: Using
provider: { type: "openai", baseUrl: "https://api.business.githubcopilot.com", bearerToken: token }increateSessionbypasses the failing fetch and works — but only for GPT models (Claude/Gemini not available via this endpoint) - Related issues: GitHub Copilot CLI fails with "fetch failed" error in corporate environments with SSL inspection #333,
web_fetchand auto-update fail withTypeError: fetch failedbehind corporate proxy #2395, Failed to list available models due to duplicate CA certificates from combined system and bundled certs #869 - Workaround: Downgrade to
@github/[email protected]/@github/[email protected]
Activity
pWoLiAn commentedon Jun 24, 2026
Root cause identified
I hit this same issue in a corporate environment and traced it to the Rust native fetch layer introduced in ~v1.0.36.
Code path
web_fetch(and all internal API calls that go throughADe) funnel throughxC, which callsI.networkFetchStreamStart— a Rust native binding — instead of Node'sfetchorundici.The request is prepared in
v$n:For
web_fetch,EDealways DNS-resolves the hostname (SSRF protection), producing pinned addresses — sorustPinnedAddressesis always non-empty, andproxyEnvis always passed as an empty object{}to the Rust layer.The Rust layer interprets
proxyEnv: {}as "no proxy" rather than falling back to readingHTTP_PROXY/HTTPS_PROXYfrom the process environment.Why internal CLI API calls work but
web_fetchdoesn'tThe CLI's own GitHub API calls go through
bf→ plainfetch(url, opts)withoutrustPinnedAddresses, soproxyEnvis never set → Rust reads proxy from env vars → works correctly.Fix
In
v$n, populateproxyEnvfrom the environment instead of passing an empty object:Environment
HTTPS_PROXYenv var (set and verified)curlthrough the same proxy works fine;web_fetchtool fails withTypeError: fetch failedNODE_EXTRA_CA_CERTSdoes not help since the issue is proxy bypass, not TLS cert validationarielgee commentedon Jun 28, 2026
Got this same issue in GitHub Desktop 3.6.1 on Windows 10 behind a corporate proxy. Error surfaces when trying to generate a Copilot commit message:
arvindkannan commentedon Oct 4, 2026
got this same issue for chat :
error when trying to initiate new chat, where existing chat works