spacedriveapp/spacedrive · error · anyhow::Error
Failed to download: HTTP {}
Error message
Failed to download: HTTP {} What it means
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.
Source
Thrown at apps/cli/src/domains/update/mod.rs:151
return Err(anyhow::anyhow!(
"Failed to fetch releases: HTTP {}",
response.status()
));
}
let release: GitHubRelease = response.json().await?;
Ok(release)
}
async fn download_file(url: &str, expected_size: u64) -> Result<Vec<u8>> {
let client = reqwest::Client::builder()
.user_agent("spacedrive-cli")
.build()?;
let response = client.get(url).send().await?;
if !response.status().is_success() {
return Err(anyhow::anyhow!(
"Failed to download: HTTP {}",
response.status()
));
}
let bytes = response.bytes().await?;
if bytes.len() as u64 != expected_size {
return Err(anyhow::anyhow!(
"Downloaded file size mismatch: expected {}, got {}",
expected_size,
bytes.len()
));
}
Ok(bytes.to_vec())
}
View on GitHub (pinned to 6dfeccf211)
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
Defensive patterns
Strategy: retry
Validate before calling
#!/usr/bin/env bash
url=$(curl -s https://api.github.com/repos/spacedrive/spacedrive/releases/latest | jq -r '.assets[0].browser_download_url')
status=$(curl -s -L -o /dev/null -w '%{http_code}' "$url")
[ "$status" = 200 ] || { echo "Asset URL returned $status"; exit 2; } Try / catch
for attempt in 1..=3 {
match download_file(&asset.browser_download_url, asset.size).await {
Ok(bytes) => return Ok(bytes),
Err(e) if attempt < 3 => {
tracing::warn!(%e, attempt, "download failed, refetching metadata and retrying");
latest_release = fetch_latest_release(repo).await?; // asset URL may have changed
}
Err(e) => return Err(e),
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Long-lived daemon processes caching release metadata; release edits happening concurrently with updates; restrictive egress filters.
Related errors
- Failed to fetch releases: HTTP {}
- Downloaded file size mismatch: expected {}, got {}
- No paired devices found. Pair a device first with: sd networ
- Remote device {} is not online
- Could not find sd binary for platform: {}
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/f515fc1fc66df670.
Report an issue: GitHub.