{"record":{"id":"335e9bbd1d0976bf","repo":"Hmbown/CodeWhale","slug":"failed-to-download-url","errorCode":null,"errorMessage":"failed to download {url}","messagePattern":"failed to download (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/update.rs","lineNumber":1592,"sourceCode":"            Ok((status, bytes)) if status.is_success() => return Ok(bytes),\n            Ok((status, bytes)) => {\n                let body = String::from_utf8_lossy(&bytes);\n                let error = anyhow!(\"download failed with HTTP {status}: {body}\");\n                if should_retry_http_status(status) && attempt < UPDATE_HTTP_ATTEMPTS {\n                    last_error = Some(error);\n                    sleep_before_update_retry(attempt);\n                    continue;\n                }\n                return Err(error);\n            }\n            Err(error) if attempt < UPDATE_HTTP_ATTEMPTS => {\n                last_error = Some(error);\n                sleep_before_update_retry(attempt);\n            }\n            Err(error) => return Err(error),\n        }\n    }\n    Err(last_error.unwrap_or_else(|| anyhow!(\"failed to download {url}\")))\n}\n\nfn download_url_once(\n    url: &str,\n    proxy: Option<&Proxy>,\n    timeout: Duration,\n) -> Result<(reqwest::StatusCode, Vec<u8>)> {\n    let client = update_http_client_with_timeout(proxy, timeout)?;\n    let response = client\n        .get(url)\n        .send()\n        .with_context(|| format!(\"failed to download {url}\"))?;\n    let status = response.status();\n    let bytes = response\n        .bytes()\n        .with_context(|| format!(\"failed to read response body from {url}\"))?;\n\n    Ok((status, bytes.to_vec()))","sourceCodeStart":1574,"sourceCodeEnd":1610,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/update.rs#L1574-L1610","documentation":"The CLI self-updater downloads the new release binary from `url` with retries; this is the terminal error returned once every retry attempt has failed. The final message is the generic fallback `anyhow!(\"failed to download {url}\")` used only when the retry loop exhausts without a concrete recorded error, though normally `last_error` carries the real transport error from the last attempt.","triggerScenarios":"Calling the CLI update check/install path when `download_url_once` returns `Err` on every attempt (network outage, proxy failure, timeout, HTTP error) until the retry budget is exhausted.","commonSituations":"Corporate proxy misconfiguration, DNS failures, GitHub releases unreachable or rate-limited, or an overly short download timeout on a slow connection.","solutions":["Check basic network reachability of the download URL (curl the URL shown in the message).","Verify proxy settings (HTTP_PROXY/HTTPS_PROXY or the `proxy` config) — a bad proxy fails every retry.","Increase or clear the download timeout configuration and retry the update.","As a fallback, download and install the release manually from the project's releases page."],"exampleFix":"// before: update fails behind proxy\n$ codewhale update\n// after: export working proxy, retry\n$ export HTTPS_PROXY=http://proxy.corp:8080\n$ codewhale update","handlingStrategy":"retry","validationCode":"import std.net;\n// pre-check reachability before invoking the updater\nlet host = url.host_str().ok_or(\"no host\")?;\nstd::net::TcpStream::connect((host, 443)).map_err(|e| format!(\"unreachable: {e}\"))?;","typeGuard":null,"tryCatchPattern":"match cli.update() {\n    Err(e) if e.to_string().contains(\"failed to download\") => {\n        eprintln!(\"network issue, falling back to manual install: {e}\");\n        print_manual_install_instructions();\n    }\n    Err(e) => return Err(e),\n    Ok(()) => {}\n}","preventionTips":["Verify proxy env vars before running updates in corporate networks","Pre-check reachability of the releases host with a lightweight HEAD request","Pin a known-good version and update manually in air-gapped environments"],"tags":["network","download","update","cli"],"backgroundTag":"http-request-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}