Hmbown/CodeWhale · error · anyhow

GET error

Error message

GET error: {e}

What it means

The same 5-second-bounded GET preflight in `try_establish_session`: the request completed but the underlying HTTP client returned an error (connection failure, TLS error, reset, DNS failure). The client error is interpolated into "GET error: {e}".

Solutions

  1. Read the interpolated `{e}` cause and act on it (connection refused → server down; certificate error → fix TLS trust).
  2. Verify the MCP server URL/port and that the service is running (curl the endpoint).
  3. Check proxy/TLS environment (HTTPS_PROXY, corporate CA bundle) that reqwest honors.
  4. Retry — transient resets often succeed on a second connection.
Defensive patterns

Strategy: retry

Validate before calling

// validate the MCP URL is reachable before connecting
let parsed = reqwest::Url::parse(url)?;
let host = parsed.host_str().ok_or("missing host")?;
eprintln!("connecting to {host}..."); // then curl/DNS check in tooling

Try / catch

match connect_with_policy(...) {
    Err(e) if e.to_string().starts_with("GET error:") => {
        let cause = e.to_string();
        if cause.contains("certificate") { /* fix TLS trust */ }
        else if cause.contains("refused") { /* server down; retry later */ }
    }
    other => other?,
}

Prevention

When it happens

Trigger: The GET request in the session-establishment select arm fails at the transport layer: server unreachable, TLS handshake failure, connection reset, malformed URL, or proxy misconfiguration.

Common situations: MCP server is down or the port is wrong; self-signed/expired TLS certificates; DNS changes after a redeploy; HTTP proxy env vars routing the request through a broken proxy.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/69769347dc1313ab. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/mcp/http.rs:222

            biased;
            _ = cancel.cancelled() => {
                anyhow::bail!("MCP session preflight cancelled after plugin authority changed")
            }
            headers = transport.auth.resolved_headers() => headers?,
        };
        let request = apply_safe_custom_headers(
            with_default_mcp_http_headers(transport.client.get(&transport.url), false),
            &headers,
        );
        let response = tokio::select! {
            biased;
            _ = cancel.cancelled() => {
                anyhow::bail!("MCP session preflight cancelled after plugin authority changed")
            }
            response = tokio::time::timeout(Duration::from_secs(5), transport.client.send(request)) => {
                response
                    .map_err(|_| anyhow::anyhow!("GET timeout"))?
                    .map_err(|e| anyhow::anyhow!("GET error: {e}"))?
            }
        };

        // Capture session ID from the GET response so subsequent POSTs
        // (including `initialize`) can include it. This is the same
        // header-reading logic that would be hit inside
        // `StreamableHttpTransport::send` for POST responses, but since
        // the GET is sent before any POST we do it here directly.
        if let Some(sid) = response
            .headers()
            .get("Mcp-Session-Id")
            .and_then(|v| v.to_str().ok())
            && transport.session_id.as_deref() != Some(sid)
        {
            let session_ref = crate::utils::redacted_identifier_for_log(sid);
            tracing::debug!(target: "mcp", session = %session_ref, "captured MCP session ID via GET preflight");
            transport.session_id = Some(sid.to_string());
        }

View on GitHub (pinned to 73e0f67d83)