{"record":{"id":"fbe7c316b4a0c393","repo":"tonhowtf/omniget","slug":"download-de-falhou-http-spicetify","errorCode":null,"errorMessage":"download de {} falhou: HTTP {}","messagePattern":"download de (.+?) falhou: HTTP (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/spicetify.rs","lineNumber":422,"sourceCode":"                    .as_str()\n                    .and_then(integrity::parse_github_digest),\n            });\n        }\n    }\n    Err(anyhow!(\n        \"release {} de {} nao tem um asset para este sistema\",\n        tag,\n        repo\n    ))\n}\n\nasync fn download_verified(\n    client: &reqwest::Client,\n    asset: &ReleaseAsset,\n) -> anyhow::Result<Vec<u8>> {\n    let response = client.get(&asset.url).send().await?;\n    if !response.status().is_success() {\n        return Err(anyhow!(\n            \"download de {} falhou: HTTP {}\",\n            asset.name,\n            response.status()\n        ));\n    }\n    let bytes = response.bytes().await?.to_vec();\n    // O GitHub publica o digest de todo asset; sem ele algo está errado na\n    // resposta, e o binário vai ser executado. Fail-closed.\n    let expected = asset.digest.as_deref().ok_or_else(|| {\n        anyhow!(\n            \"{} veio sem digest da API do GitHub; download descartado\",\n            asset.name\n        )\n    })?;\n    integrity::verify_sha256(&bytes, expected, &asset.name)?;\n    Ok(bytes)\n}\n","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/spicetify.rs#L404-L440","documentation":"`download_verified` fetches the release asset's browser_download URL and requires an HTTP success status. Any non-2xx (404 stale URL, 403 rate limit, 5xx) aborts with this error naming the asset and status. Nothing is written to disk before this check.","triggerScenarios":"`download_verified(client, asset)` where GET on `asset.url` fails: asset removed after release edit, expired/redirected CDN URL, rate-limited download, transient GitHub/CDN outage.","commonSituations":"Using a cached asset URL from an old release; downloading during a GitHub incident; network proxies blocking github.com/object storage; flaky mobile/corporate networks.","solutions":["Re-fetch the latest release via `latest_asset` to get a fresh asset URL, then retry","Check the HTTP status: 403/429 = rate limit — wait or use a token; 404 = URL stale","Test the URL manually with curl to confirm it's a network/CDN issue","Add retry with exponential backoff for transient 5xx/network errors"],"exampleFix":"// before\nlet bytes = download_verified(&client, &asset).await?;\n// after\nlet bytes = loop {\n    match download_verified(&client, &asset).await {\n        Ok(b) => break b,\n        Err(e) if attempts < 3 => { attempts += 1; sleep(Duration::from_secs(2u64.pow(attempts))).await; }\n        Err(e) => return Err(e),\n    }\n};","handlingStrategy":"retry","validationCode":"let head = client.get(&asset.url).send().await?;\nif !head.status().is_success() { eprintln!(\"asset URL unhealthy: {}\", head.status()); }","typeGuard":null,"tryCatchPattern":"let mut delay = Duration::from_secs(1);\nloop {\n    match download_verified(&client, &asset).await {\n        Ok(b) => break Ok(b),\n        Err(e) if e.to_string().contains(\"download\") && retries < 3 => {\n            retries += 1; sleep(delay).await; delay *= 2;\n        }\n        Err(e) => break Err(e),\n    }\n}","preventionTips":["Always re-resolve the asset URL from the latest release before downloading; never cache URLs long-term","Retry transient failures with exponential backoff","Detect rate limiting (403/429) and wait instead of hammering","Use the digest verification flow so partial/corrupt downloads are discarded"],"tags":["network","download","http"],"backgroundTag":"http-request-failed","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}