{"record":{"id":"4d80872b165d926a","repo":"gitbutlerapp/gitbutler","slug":"download-failed-with-http-status-response-code","errorCode":null,"errorMessage":"Download failed with HTTP status: {response_code}","messagePattern":"Download failed with HTTP status: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-installer/src/download.rs","lineNumber":129,"sourceCode":"            return Err(io_err).context(\"Failed to write downloaded data\");\n        }\n\n        // If perform failed for other reasons, propagate that error\n        perform_result.with_context(|| format!(\"Failed to download from {url}\"))?;\n    }\n\n    // Clear progress line\n    crate::ui::println_empty();\n\n    let response_code = easy\n        .response_code()\n        .context(\"Failed to get response code\")?;\n    if response_code == 403 {\n        bail!(\n            \"Download failed, the download artifact could not be found. Most likely, the but CLI has not been published for the requested version.\"\n        )\n    } else if response_code != 200 {\n        bail!(\"Download failed with HTTP status: {response_code}\");\n    }\n\n    // Validate the effective URL after following redirects\n    // This protects against malicious redirects to untrusted domains or insecure protocols\n    let effective_url = easy\n        .effective_url()\n        .context(\"Failed to get effective URL\")?\n        .ok_or_else(|| anyhow!(\"Effective URL is missing\"))?;\n\n    crate::release::validate_download_url(effective_url)\n        .with_context(|| format!(\"Download was redirected to an untrusted URL: {effective_url}\"))?;\n\n    Ok(())\n}\n","sourceCodeStart":111,"sourceCodeEnd":144,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-installer/src/download.rs#L111-L144","documentation":"Generic failure branch of `download_file`: the artifact download endpoint returned a non-200, non-403 status. Unlike the 403 case, this does not imply the artifact is missing — it signals a server/network problem and bails with the raw status code.","triggerScenarios":"The release CDN returns 500/502/503 during an outage; a proxy returns 401/407; rate limiting returns 429; any intermediary error page replaces the binary download.","commonSituations":"Downloading during a CDN or GitHub releases outage; corporate MITM proxies intercepting the request; too many downloads triggering throttling.","solutions":["Read the status code in the message: retry on 5xx/429 after a backoff; fix proxy/auth config on 401/407.","Check the GitButler release server status / your network connectivity.","Retry the install command; transient server errors usually clear on their own.","If persistent, download the artifact manually with curl to inspect the actual response body."],"exampleFix":"// before\ndownload_and_install_app(&config)?;\n// after\nfor attempt in 0..3 {\n    match download_and_install_app(&config) {\n        Ok(()) => break,\n        Err(e) if e.to_string().contains(\"HTTP status: 5\") && attempt < 2 => {\n            std::thread::sleep(Duration::from_secs(2u64.pow(attempt)));\n        }\n        Err(e) => return Err(e),\n    }\n}","handlingStrategy":"retry","validationCode":"// probe endpoint health before the real download\nlet probe = reqwest::blocking::get(&url)?;\nif probe.status().is_server_error() {\n    anyhow::bail!(\"artifact server unhealthy ({})\", probe.status());\n}","typeGuard":null,"tryCatchPattern":"match download_and_install_app(&config) {\n    Err(e) if e.to_string().contains(\"HTTP status: 429\") => { wait_rate_limit(); retry()? }\n    Err(e) if e.to_string().contains(\"HTTP status: 5\") => retry_with_backoff(3)?,\n    Err(e) => return Err(e),\n    Ok(()) => Ok(()),\n}","preventionTips":["Implement exponential backoff for 5xx/429 responses.","Check proxy/firewall settings if behind a corporate network that injects error pages.","Monitor the release-host status page during upgrade windows.","Avoid hammering the download endpoint in loops (throttling)."],"tags":["network","http","download"],"backgroundTag":"http-error-response","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}