{"record":{"id":"1fc38d6931f7c49a","repo":"tonhowtf/omniget","slug":"reddit-retornou-http-mod","errorCode":null,"errorMessage":"Reddit retornou HTTP {}","messagePattern":"Reddit retornou HTTP (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/platforms/reddit/mod.rs","lineNumber":131,"sourceCode":"        if Self::is_share_link(url) {\n            return redirect::resolve_redirect(&self.client, url).await;\n        }\n\n        Ok(url.to_string())\n    }\n\n    async fn fetch_post_data(&self, post_id: &str) -> anyhow::Result<serde_json::Value> {\n        let url = format!(\"https://www.reddit.com/comments/{}.json\", post_id);\n\n        let response = self\n            .client\n            .get(&url)\n            .header(\"Accept\", \"application/json\")\n            .send()\n            .await?;\n\n        if !response.status().is_success() {\n            return Err(anyhow!(\"Reddit retornou HTTP {}\", response.status()));\n        }\n\n        let json: serde_json::Value = response.json().await?;\n\n        if !json.is_array() {\n            return Err(anyhow!(\"Post not found\"));\n        }\n\n        json.as_array()\n            .and_then(|arr| arr.first())\n            .and_then(|listing| listing.pointer(\"/data/children/0/data\"))\n            .cloned()\n            .ok_or_else(|| anyhow!(\"Post not found\"))\n    }\n\n    fn construct_audio_url(fallback_url: &str) -> Vec<String> {\n        let video = fallback_url.split('?').next().unwrap_or(fallback_url);\n        let mut candidates = Vec::new();","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/platforms/reddit/mod.rs#L113-L149","documentation":"fetch_post_data performs a GET against Reddit's .json endpoint and rejects any non-success HTTP status with this localized error, embedding the status code. It is thrown before any JSON parsing so the caller never gets partial data.","triggerScenarios":"Calling native_get_media_info on a Reddit URL when reddit.com responds 403 (blocked/ rate limited), 404 (post deleted), 429 (rate limited), or 5xx; corporate/VPN egress IP blocked by Reddit.","commonSituations":"Datacenter/VPN IPs being soft-banned by Reddit; post removed by moderators (404); hitting Reddit without a User-Agent/oauth token at high volume; temporary Reddit outages.","solutions":["Retry after a delay if the status is 429; respect the Retry-After header.","Set a descriptive User-Agent header on the reqwest client to reduce 403s.","Use Reddit's OAuth API with credentials instead of anonymous .json endpoints for reliable access.","Check the post URL in a browser — if it 404s the post was deleted/removed.","Log response.status() and body text to distinguish blocking (403) from missing content (404)."],"exampleFix":"// before\nif !response.status().is_success() {\n    return Err(anyhow!(\"Reddit retornou HTTP {}\", response.status()));\n}\n// after\nif !response.status().is_success() {\n    let status = response.status();\n    let body = response.text().await.unwrap_or_default();\n    if status == reqwest::StatusCode::TOO_MANY_REQUESTS {\n        anyhow::bail!(\"Reddit rate limit hit (HTTP 429); retry later\");\n    }\n    anyhow::bail!(\"Reddit retornou HTTP {} : {}\", status, body);\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// retry only transient statuses\nmatch fetch(url).await {\n    Err(e) if e.to_string().contains(\"HTTP 429\") || e.to_string().contains(\"HTTP 5\") => {\n        tokio::time::sleep(Duration::from_secs(5)).await;\n        fetch(url).await\n    }\n    other => other,\n}","preventionTips":["Set a descriptive User-Agent on the HTTP client","Rate-limit Reddit requests and respect Retry-After on 429","Prefer OAuth-authenticated API calls over anonymous .json endpoints","Verify post URLs in a browser when you get persistent 404/403"],"tags":["reddit","http","network","rate-limit"],"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"}