{"record":{"id":"1b67a61ad25af794","repo":"tonhowtf/omniget","slug":"reddit-retornou-http","errorCode":null,"errorMessage":"Reddit retornou HTTP {}","messagePattern":"Reddit retornou HTTP (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/platforms/reddit.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/omniget-core/src/platforms/reddit.rs#L113-L149","documentation":"fetch_post_data requests the Reddit JSON API (.json endpoint) and checks the HTTP status before parsing. If Reddit responds with a non-2xx status (404 removed post, 403 quarantine/private, 429 rate limit, 5xx outage), the library surfaces it as this anyhow error with the status code embedded in the message, aborting media-info extraction.","triggerScenarios":"Reddit's JSON endpoint returns 404/403/429/5xx during response.send() in fetch_post_data, called from native_get_media_info for a given post URL.","commonSituations":"Deleted or removed posts, private/quarantined subreddits, Reddit rate limiting (429) from too many requests without OAuth, or Reddit CDN/API outages returning 5xx.","solutions":["Verify the post URL opens in a browser (post not deleted/removed) before calling the API.","Inspect the status code in the message: 429 means slow down / add retry with backoff; 403 may require authentication headers or a valid User-Agent.","Retry after a delay for transient 5xx responses; consider adding a proper User-Agent string to the reqwest client to reduce blocking.","If 403 persists, check whether the subreddit is quarantined/private and use authenticated access."],"exampleFix":"// before\nlet resp = self.client.get(&url).header(\"Accept\", \"application/json\").send().await?;\nif !resp.status().is_success() {\n    return Err(anyhow!(\"Reddit retornou HTTP {}\", resp.status()));\n}\n// after: add User-Agent and retry on transient failures\nlet resp = self.client.get(&url)\n    .header(\"Accept\", \"application/json\")\n    .header(\"User-Agent\", \"omniget/1.0\")\n    .send().await?;\nif resp.status() == reqwest::StatusCode::TOO_MANY_REQUESTS {\n    tokio::time::sleep(Duration::from_secs(2)).await;\n    return self.fetch_post_data(post_id).await; // retry\n}\nif !resp.status().is_success() {\n    return Err(anyhow!(\"Reddit retornou HTTP {}\", resp.status()));\n}","handlingStrategy":"retry","validationCode":"// pre-check reachability before calling the library\nlet head = reqwest::Client::new()\n    .head(&post_url)\n    .header(\"User-Agent\", \"omniget/1.0\")\n    .send().await?;\nif head.status() == reqwest::StatusCode::NOT_FOUND {\n    return Err(anyhow!(\"Post is gone (404); skip\"));\n}","typeGuard":null,"tryCatchPattern":"match native_get_media_info(url).await {\n    Err(e) if e.to_string().contains(\"HTTP 429\") => schedule_retry_with_backoff(url),\n    Err(e) if e.to_string().contains(\"HTTP 4\") => show_user(\"Post unavailable\"),\n    Err(e) => retry_transient(url, e),\n    Ok(info) => use(info),\n}","preventionTips":["Set a descriptive User-Agent on the client to avoid Reddit's default-UA blocking.","Throttle requests and back off on 429 to stay under Reddit rate limits.","Verify post URLs in a browser before batch processing.","Retry transient 5xx with exponential backoff."],"tags":["network","http","reddit","api-error-response"],"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"}