Skip to content

[Bug]: Fetch tool ignores HTTP_PROXY/HTTPS_PROXY — uses bare reqwest::Client bypassing proxy configuration #3329

@sleicht

Description

@sleicht

Description

The ForgeFetch tool (crates/forge_services/src/tool_services/fetch.rs) creates its own bare reqwest::Client via Client::new(), completely bypassing the proxy-aware, properly configured HTTP client used by the rest of the application (ForgeHttpInfra in crates/forge_infra/src/http.rs).

Since the workspace enables the hickory-dns Cargo feature for reqwest, the bare client attempts direct DNS resolution, which fails in corporate proxy environments even when HTTP_PROXY/HTTPS_PROXY environment variables are correctly set.

The main ForgeHttpInfra client already handles this correctly by calling .hickory_dns(false) on the builder — the fetch tool just needs the same treatment.

Steps to Reproduce

  1. Set HTTP_PROXY and HTTPS_PROXY to a corporate proxy (e.g. http://proxy.corp:8080)
  2. Use the fetch tool to load any URL (e.g. https://example.com)
  3. Observe: Failed to fetch URL https://example.com/: error sending request for url
  4. Meanwhile, curl https://example.com works fine (respects proxy env vars)

Root Cause

In crates/forge_services/src/tool_services/fetch.rs:

impl ForgeFetch {
    pub fn new() -> Self {
        Self { client: Client::new() }  // bare client, no proxy/hickory config
    }
}

vs. the properly configured client in crates/forge_infra/src/http.rs:

let mut client = reqwest::Client::builder()
    // ... timeouts, TLS, etc.
    .hickory_dns(http.hickory)  // defaults to false — proxy-safe
    // ...

Suggested Fix

Either:

  1. (Preferred) Have ForgeFetch accept and use the shared ForgeHttpInfra client instead of constructing its own
  2. (Minimal) Disable hickory-dns on the fetch client:
pub fn new() -> Self {
    Self {
        client: Client::builder()
            .hickory_dns(false)
            .build()
            .unwrap()
    }
}

Related

Environment

  • Forge Code version: 2.1.140
  • OS: macOS (ARM64)
  • Corporate proxy via HTTP_PROXY/HTTPS_PROXY env vars
  • curl works correctly through the proxy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions