github / github/copilot-cli

web_fetch tool fails on all URLs (TypeError: fetch failed) in IPv4-only sandbox environments

未關閉
#4,041 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
area:networking area:tools
主要語言
Shell
星號
11.2k
分支
1.9k
平均合併
14 小時 16 分鐘
30 天內合併 PR
6

描述

### Description

The built-in `web_fetch` tool fails on **every** URL, including trivial always-up test sites (e.g. `https://example.com`), returning a generic error:

```
TypeError: fetch failed
```

This happens both with `raw: true` and default markdown mode, and regardless of the target site (tested `https://example.com` and `https://www.intel.com/...`).

### Environment

- CLI version: 1.0.68
- OS: Linux (Copilot CLI cloud/session sandbox)
- Host network: no global IPv6 address on the primary interface (`eth0` only has a link-local `fe80::/64` address; `ip -6 route show` shows no default IPv6 route)

### Steps to reproduce

1. In a Copilot CLI session, invoke the `web_fetch` tool against `https://example.com`.
2. Observe `TypeError: fetch failed` with no further detail.

### Diagnosis / evidence that this is not a general network outage

From the same session's bash shell:
- `curl https://example.com` → succeeds (`HTTP 200`)
- `curl -4 https://example.com` (IPv4 forced) → succeeds consistently
- `curl -6 https://example.com` (IPv6 forced) → fails consistently: `Failed to connect to example.com port 443 ... Couldn't connect to server`
- Plain Node `fetch()` (same Node runtime available in the sandbox, v24.13.0) → succeeds, because Node's `fetch`/undici implementation performs Happy-Eyeballs-style fallback from IPv6 to IPv4 automatically
- DNS resolves both `A` (IPv4) and `AAAA` (IPv6) records for the target domains

This strongly suggests the `web_fetch` tool's underlying HTTP client attempts the IPv6 (`AAAA`) address first (as returned by DNS) and does not fall back to IPv4 on failure, causing an immediate, opaque `TypeError: fetch failed` in environments where IPv6 egress is unavailable (no global IPv6 address/route on the host, only link-local).

I even tried disabling IPv6 system-wide on the sandbox host via `sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1` (and `default`) — `curl`/Node fetch continued to work fine afterward, but `web_fetch` still failed identically. This indicates `web_fetch` likely executes in a separate process/container from the interactive bash sandbox, so host-level network changes made from within the session don't reach it — the fix needs to happen wherever that tool's HTTP client actually runs.

### Expected behavior

`web_fetch` should successfully fetch pages in environments with IPv4-only egress, ideally by:
- Implementing Happy Eyeballs / IPv4 fallback when IPv6 connection attempts fail, and/or
- Surfacing a more actionable error message (e.g., distinguishing DNS failure vs. connection refused vs. TLS failure) instead of a generic `TypeError: fetch failed`.

### Workaround

Using `curl` via the `bash` tool as a substitute for `web_fetch` works reliably in the same session.

貢獻指南

開啟貢獻指南

研究方向

先找出 web_fetch 的進入點及其使用的 HTTP client process;將其行為與 Node v24.13.0 fetch/undici 以及此處描述的僅 IPv4 重現進行比較。完成的標準是:在 IPv6 egress 無法使用時 web_fetch 仍能成功,或回報更具可操作性的網路錯誤;使用僅 IPv4 的連線針對 https://example.com 進行驗證。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
node.js
領域
cli, networking
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
活躍
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。