Hmbown/CodeWhale · error

reading remote bundle failed

Error message

reading remote bundle failed

What it means

Reading the bundle response body via read_to_end on the size-bounded stream failed with an I/O error. The reader is capped at MAX_BUNDLE_BYTES + 1 so oversize bodies are reported separately; this message specifically means the read itself errored (connection dropped mid-body, timeout) rather than the body being too large.

Solutions

  1. Retry the import; transient connection drops are the usual cause.
  2. Verify the server serves the full bundle (compare content-length / download with curl).
  3. Check for proxies or load balancers with short body timeouts.
  4. Reduce bundle size if the server has trouble streaming it.
Defensive patterns

Strategy: retry

Validate before calling

let head = client.head(bundle_url).send()?; let len: u64 = head.headers().get(header::CONTENT_LENGTH).and_then(|v| v.to_str().ok()?.parse().ok()).unwrap_or(0); if len > MAX { bail!("bundle too large before download"); }

Try / catch

for attempt in 0..3 { match fetch_bundle(url) { Err(e) if e.to_string().contains("reading remote bundle failed") => sleep_backoff(attempt), other => return other, } }

Prevention

When it happens

Trigger: The response body stream errors during body.take(MAX_BUNDLE_BYTES + 1).read_to_end() — server closed the connection prematurely, network interruption, or body read timeout.

Common situations: Flaky network or proxy dropping large downloads, server crashing while streaming the bundle, aggressive idle timeouts on long transfers.

Related errors


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

Appendix: source

Thrown at crates/cli/src/config_bundles.rs:807

        validate_bundle_redirect(&initial_scheme, &next_url)?;
        current_url = next_url;
        redirects += 1;
    };

    if !response.status().is_success() {
        bail!(
            "bundle fetch failed with HTTP status {}",
            response.status().as_u16()
        );
    }

    // Read at most MAX_BUNDLE_BYTES + 1 so an oversize body is detected
    // rather than silently truncated.
    let mut buffer = Vec::new();
    let body = response;
    body.take(MAX_BUNDLE_BYTES + 1)
        .read_to_end(&mut buffer)
        .map_err(|_| anyhow!("reading remote bundle failed"))?;
    if buffer.len() as u64 > MAX_BUNDLE_BYTES {
        bail!("remote bundle exceeds the {MAX_BUNDLE_BYTES} byte limit; refused");
    }
    Ok(buffer)
}

fn validate_bundle_url(url: &reqwest::Url) -> Result<()> {
    if !matches!(url.scheme(), "http" | "https") {
        bail!("unsupported bundle URL scheme; use https");
    }
    if !url.username().is_empty() || url.password().is_some() {
        bail!("bundle URLs may not include credentials");
    }
    let host = url.host_str().context("bundle URL must include a host")?;
    match url.scheme() {
        "https" => Ok(()),
        "http" if is_loopback_bundle_host(host) => Ok(()),
        "http" => bail!("plain http is only allowed for loopback hosts; use https"),

View on GitHub (pinned to 73e0f67d83)