{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/update.rs","lineNumber":1140,"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(url: &str, proxy: Option<&Proxy>) -> Result<(reqwest::StatusCode, Vec<u8>)> {\n    let client = update_http_client(proxy)?;\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()))\n}\n\n/// Compute the SHA256 hex digest of data.\nfn sha256_hex(data: &[u8]) -> String {","sourceCodeStart":1122,"sourceCodeEnd":1158,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/cli/src/update.rs#L1122-L1158","documentation":"Defensive fallback arm of download_url's retry loop: returned only if the loop (1..=UPDATE_HTTP_ATTEMPTS, currently 3) finishes without recording an error. Every real failure carries the HTTP status or transport context; this message has no cause and is unreachable in shipped builds.","triggerScenarios":"Only if UPDATE_HTTP_ATTEMPTS were 0 or the loop were rewritten; genuine download problems surface through the HTTP-status or transport arms with detailed messages.","commonSituations":"Practically none in shipped builds; it exists so the function is total for the compiler.","solutions":["Treat as an internal invariant violation and report the build","If maintaining a fork, keep UPDATE_HTTP_ATTEMPTS >= 1","Diagnose the real failure from the preceding transport errors, not this message"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Propagate as an internal error with no retry: the message has no attached cause, so any retry decision must come from the preceding transport errors in your own logs.","preventionTips":["Keep UPDATE_HTTP_ATTEMPTS >= 1 in custom builds"],"tags":["network","http","download","unreachable","defensive"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}