{"record":{"id":"f515fc1fc66df670","repo":"spacedriveapp/spacedrive","slug":"failed-to-download-http","errorCode":null,"errorMessage":"Failed to download: HTTP {}","messagePattern":"Failed to download: HTTP (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"apps/cli/src/domains/update/mod.rs","lineNumber":151,"sourceCode":"\t\treturn Err(anyhow::anyhow!(\n\t\t\t\"Failed to fetch releases: HTTP {}\",\n\t\t\tresponse.status()\n\t\t));\n\t}\n\n\tlet release: GitHubRelease = response.json().await?;\n\tOk(release)\n}\n\nasync fn download_file(url: &str, expected_size: u64) -> Result<Vec<u8>> {\n\tlet client = reqwest::Client::builder()\n\t\t.user_agent(\"spacedrive-cli\")\n\t\t.build()?;\n\n\tlet response = client.get(url).send().await?;\n\n\tif !response.status().is_success() {\n\t\treturn Err(anyhow::anyhow!(\n\t\t\t\"Failed to download: HTTP {}\",\n\t\t\tresponse.status()\n\t\t));\n\t}\n\n\tlet bytes = response.bytes().await?;\n\n\tif bytes.len() as u64 != expected_size {\n\t\treturn Err(anyhow::anyhow!(\n\t\t\t\"Downloaded file size mismatch: expected {}, got {}\",\n\t\t\texpected_size,\n\t\t\tbytes.len()\n\t\t));\n\t}\n\n\tOk(bytes.to_vec())\n}\n","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/apps/cli/src/domains/update/mod.rs#L133-L169","documentation":"download_file() streams the asset's browser_download_url and rejects non-2xx responses. Unlike the API call, this hits GitHub's asset CDN; failures are usually 404 (asset deleted/renamed after the release metadata was fetched), 403, or proxy-generated error codes.","triggerScenarios":"An asset was removed or re-uploaded between the releases/latest call and the download; expired signed URL behind a cache; proxy blocking the CDN host.","commonSituations":"Long-lived daemon processes caching release metadata; release edits happening concurrently with updates; restrictive egress filters.","solutions":["Retry 'sd update' so fresh release metadata is fetched","Open the printed download URL in a browser/curl to see the exact status","Bypass the proxy or download the artifact manually"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"#!/usr/bin/env bash\nurl=$(curl -s https://api.github.com/repos/spacedrive/spacedrive/releases/latest | jq -r '.assets[0].browser_download_url')\nstatus=$(curl -s -L -o /dev/null -w '%{http_code}' \"$url\")\n[ \"$status\" = 200 ] || { echo \"Asset URL returned $status\"; exit 2; }","typeGuard":null,"tryCatchPattern":"for attempt in 1..=3 {\n    match download_file(&asset.browser_download_url, asset.size).await {\n        Ok(bytes) => return Ok(bytes),\n        Err(e) if attempt < 3 => {\n            tracing::warn!(%e, attempt, \"download failed, refetching metadata and retrying\");\n            latest_release = fetch_latest_release(repo).await?; // asset URL may have changed\n        }\n        Err(e) => return Err(e),\n    }\n}","preventionTips":["Refetch release metadata before each retry so you never use a stale download URL","Follow redirects (-L / reqwest default) when fetching asset URLs","Surface the HTTP status and asset name in the error for quick diagnosis"],"tags":["network","http","update","cdn"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}