tonhowtf/omniget · error

Reddit retornou HTTP

Error message

Reddit retornou HTTP {}

What it means

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.

Solutions

  1. Retry after a delay if the status is 429; respect the Retry-After header.
  2. Set a descriptive User-Agent header on the reqwest client to reduce 403s.
  3. Use Reddit's OAuth API with credentials instead of anonymous .json endpoints for reliable access.
  4. Check the post URL in a browser — if it 404s the post was deleted/removed.
  5. Log response.status() and body text to distinguish blocking (403) from missing content (404).

Example fix

// before
if !response.status().is_success() {
    return Err(anyhow!("Reddit retornou HTTP {}", response.status()));
}
// after
if !response.status().is_success() {
    let status = response.status();
    let body = response.text().await.unwrap_or_default();
    if status == reqwest::StatusCode::TOO_MANY_REQUESTS {
        anyhow::bail!("Reddit rate limit hit (HTTP 429); retry later");
    }
    anyhow::bail!("Reddit retornou HTTP {} : {}", status, body);
}
Defensive patterns

Strategy: retry

Try / catch

// retry only transient statuses
match fetch(url).await {
    Err(e) if e.to_string().contains("HTTP 429") || e.to_string().contains("HTTP 5") => {
        tokio::time::sleep(Duration::from_secs(5)).await;
        fetch(url).await
    }
    other => other,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/1fc38d6931f7c49a. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/src/platforms/reddit/mod.rs:131

        if Self::is_share_link(url) {
            return redirect::resolve_redirect(&self.client, url).await;
        }

        Ok(url.to_string())
    }

    async fn fetch_post_data(&self, post_id: &str) -> anyhow::Result<serde_json::Value> {
        let url = format!("https://www.reddit.com/comments/{}.json", post_id);

        let response = self
            .client
            .get(&url)
            .header("Accept", "application/json")
            .send()
            .await?;

        if !response.status().is_success() {
            return Err(anyhow!("Reddit retornou HTTP {}", response.status()));
        }

        let json: serde_json::Value = response.json().await?;

        if !json.is_array() {
            return Err(anyhow!("Post not found"));
        }

        json.as_array()
            .and_then(|arr| arr.first())
            .and_then(|listing| listing.pointer("/data/children/0/data"))
            .cloned()
            .ok_or_else(|| anyhow!("Post not found"))
    }

    fn construct_audio_url(fallback_url: &str) -> Vec<String> {
        let video = fallback_url.split('?').next().unwrap_or(fallback_url);
        let mut candidates = Vec::new();

View on GitHub (pinned to 8600b91f42)