{"record":{"id":"2308d244f4acddba","repo":"nikivdev/code","slug":"download-failed","errorCode":null,"errorMessage":"download failed ({})","messagePattern":"download failed \\((.+?)\\)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/registry.rs","lineNumber":241,"sourceCode":"    let version = opts.version.clone();\n    let manifest = fetch_manifest(&client, &registry_url, &name, version.as_deref())?;\n    let target = detect_target_triple()?;\n    let target_entry = manifest\n        .targets\n        .get(&target)\n        .with_context(|| format!(\"No binaries for target {}\", target))?;\n    let bin = resolve_install_bin(&name, &opts.bin, &manifest, target_entry)?;\n    let path = target_entry\n        .binaries\n        .get(&bin)\n        .with_context(|| format!(\"No binary '{}' in manifest\", bin))?;\n    let download_url = resolve_download_url(&registry_url, path);\n    let response = client\n        .get(download_url)\n        .send()\n        .context(\"failed to download binary\")?;\n    if !response.status().is_success() {\n        bail!(\"download failed ({})\", response.status());\n    }\n    let bytes = response.bytes().context(\"failed to read download\")?;\n\n    if !opts.no_verify {\n        if let Some(expected) = target_entry.sha256.get(&bin) {\n            let actual = sha256_bytes(&bytes);\n            if expected != &actual {\n                bail!(\"checksum mismatch for {}\", bin);\n            }\n        }\n    }\n\n    let bin_dir = opts.bin_dir.clone().unwrap_or_else(default_bin_dir);\n    fs::create_dir_all(&bin_dir)\n        .with_context(|| format!(\"failed to create {}\", bin_dir.display()))?;\n    let dest = bin_dir.join(&bin);\n    if dest.exists() && !opts.force {\n        bail!(","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/registry.rs#L223-L259","documentation":"install downloads the binary from the resolved download URL. If the HTTP response status is not successful, it bails with 'download failed (<status>)'. The `.context(\"failed to download binary\")` only covers transport errors; this error covers server-side rejections.","triggerScenarios":"GET on the resolved binary URL returning 404 (package/version/target not published), 401/403 (private package), or 5xx, after a successful manifest fetch.","commonSituations":"Requesting a version whose manifest exists but binaries were never uploaded; wrong target triple published; registry URL misconfigured pointing at the wrong host; package removed from the registry.","solutions":["Check the status code: 404 means the binary isn't published for that package/version/target — verify the version and target.","Verify the registry URL configuration resolves to the correct registry.","Re-publish the package if the binary was never uploaded.","Retry if the status is 5xx (transient registry issue)."],"exampleFix":"null","handlingStrategy":"retry","validationCode":"// Pre-flight: verify the binary entry exists in the manifest before downloading\nlet target_entry = manifest.targets.get(&target_triple)\n    .ok_or_else(|| format!(\"no binaries published for target {}\", target_triple))?;\nif !target_entry.sha256.contains_key(&bin) {\n    return Err(format!(\"binary {} not listed for target {}\", bin, target_triple));\n}","typeGuard":null,"tryCatchPattern":"match install(opts) {\n    Err(e) if e.to_string().contains(\"download failed\") => {\n        if e.to_string().contains(\"404\") {\n            eprintln!(\"Binary not published for this package/version/target — verify version and target triple.\");\n        } else if e.to_string().contains(\"50\") {\n            retry_with_backoff(3, || install(opts.clone()));\n        }\n        std::process::exit(1);\n    }\n    other => other,\n}","preventionTips":["Verify the version exists and binaries were uploaded (not just the manifest).","Confirm the target triple matches one published in the manifest.","Double-check registry_url configuration before installs in CI.","Retry on 5xx; treat 404 as a publishing gap, not transient."],"tags":["network","http","download","registry"],"backgroundTag":"http-download-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}