{"record":{"id":"ea74dc9478bedbf2","repo":"tonhowtf/omniget","slug":"download-falhou-http","errorCode":null,"errorMessage":"download falhou: HTTP {}","messagePattern":"download falhou: HTTP (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/instagram/mod.rs","lineNumber":434,"sourceCode":"        self.absorb(&resp);\n        if resp.status().is_redirection() {\n            return Err(IgError::LoginRequired);\n        }\n        resp.text().await.map_err(|e| IgError::Other(e.to_string()))\n    }\n\n    /// Baixa um arquivo de CDN (sem cabeçalhos de API).\n    pub async fn download(&self, url: &str, dest: &std::path::Path) -> anyhow::Result<u64> {\n        use futures::StreamExt;\n        use tokio::io::AsyncWriteExt;\n        let resp = self\n            .http\n            .get(url)\n            .header(\"Referer\", \"https://www.instagram.com/\")\n            .send()\n            .await?;\n        if !resp.status().is_success() {\n            bail!(\"download falhou: HTTP {}\", resp.status());\n        }\n        if let Some(p) = dest.parent() {\n            std::fs::create_dir_all(p)?;\n        }\n        let part = dest.with_extension(\"part\");\n        let mut file = tokio::fs::File::create(&part).await?;\n        let mut stream = resp.bytes_stream();\n        let mut n = 0u64;\n        while let Some(chunk) = stream.next().await {\n            let chunk = chunk?;\n            file.write_all(&chunk).await?;\n            n += chunk.len() as u64;\n        }\n        file.flush().await?;\n        drop(file);\n        tokio::fs::rename(&part, dest).await?;\n        Ok(n)\n    }","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/instagram/mod.rs#L416-L452","documentation":"Thrown inside Instagram media `download` when the HTTP response status is not a success (non-2xx). Instagram (or an intermediate CDN/proxy) rejected the media fetch, so the tool aborts instead of writing a corrupt file.","triggerScenarios":"`download` issues a GET with `Referer: https://www.instagram.com/` and the response `resp.status().is_success()` is false — e.g. 403 for expired/signed-out CDN URLs, 404 for deleted media, 429 rate limiting.","commonSituations":"Expired Instagram CDN media URL after the item URL aged out; Instagram blocking datacenter IPs or missing auth cookies; rate-limited bulk downloads; media deleted between listing and download.","solutions":["Refresh the media URL by re-fetching the post/story metadata, then retry the download","Add valid session cookies/auth so the CDN accepts the request","Slow down: add delays/backoff between downloads to avoid HTTP 429","Check media still exists (404) — skip removed items"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// can't pre-validate remote status, but check URL freshness before download\nlet meta = fetch_media_metadata(id).await?; // re-signs/refreshes CDN URL\nif meta.url.is_empty() { skip_item(id); }","typeGuard":null,"tryCatchPattern":"match instagram::download(url, &dest).await {\n    Ok(n) => info!(\"downloaded {} bytes\", n),\n    Err(e) if e.to_string().contains(\"download falhou\") => {\n        warn!(\"HTTP failure, retrying with backoff: {}\", e);\n        retry_with_backoff(3, || instagram::download(url, &dest)).await?;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Refresh media URLs shortly before downloading — Instagram CDN links expire","Add exponential backoff and jitter for 429/5xx responses","Include valid session cookies and the Instagram Referer header","Throttle concurrent downloads to avoid rate limiting"],"tags":["network","http","instagram","download"],"backgroundTag":"http-error-response","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"}