tonhowtf/omniget · error

HTTP {} em {}

Error message

HTTP {} em {}

What it means

`Fetcher::get_json` retries the HTTP request up to TRIES times and fails with this error whenever Reddit returns any non-404 non-success status. The message embeds the status code and the requested URL so the caller can see which endpoint refused the request. It is thrown after all retries were consumed (or immediately, since only 429/5xx-style paths retry via the Err arm).

Solutions

  1. Inspect the status code in the message: 429 means slow down — increase backoff or reduce request rate
  2. If 403/418, use authenticated OAuth headers or a different IP (datacenter IPs are often blocked by Reddit)
  3. Retry later if 5xx — it is usually a transient Reddit-side outage
  4. Wrap the call so 404 (handled earlier) vs other statuses are reported distinctly to the user

Example fix

// before
let json = fetcher.get_json(&url).await?;
// after
let json = fetcher.get_json(&url).await.map_err(|e| {
    eprintln!("falha ao buscar {}: {}", url, e);
    e
})?;
Defensive patterns

Strategy: retry

Validate before calling

// nothing to check locally; optionally verify reachability first
if reqwest::get("https://www.reddit.com").await.is_err() {
    anyhow::bail!("sem acesso ao Reddit");
}

Try / catch

match fetcher.get_json(&url).await {
    Ok(v) => v,
    Err(e) if e.to_string().contains("HTTP 429") => {
        tokio::time::sleep(Duration::from_secs(30)).await;
        fetcher.get_json(&url).await?
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling get_json (directly or via thread/thread_from_fixture flows) when Reddit responds with a status other than 200 or 404 — e.g. 403 (blocked/private), 429 (rate limited past all retries), 5xx (Reddit outage) — after the retry loop in src-tauri/omniget-core/src/core/tools/reddit/mod.rs:459 exhausts TRIES.

Common situations: Hitting Reddit too aggressively (rate limit 429), Reddit partial outages (502/503), requests from blocked/datacenter IPs getting 403, or querying quarantined/private subs.

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/db2341b54e2afe1b. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/reddit/mod.rs:459

                        .get(reqwest::header::RETRY_AFTER)
                        .and_then(|v| v.to_str().ok())
                        .and_then(|v| v.trim().parse::<u64>().ok())
                        .map(Duration::from_secs);
                    tokio::time::sleep(retry.unwrap_or(wait)).await;
                    wait *= 2;
                }
                Ok(r) if r.status().as_u16() == 403 => {
                    return Err(anyhow!(
                        "o Reddit barrou o acesso público (403). Costuma ser bloqueio de rede ou conteúdo restrito: tente de outra conexão"
                    ));
                }
                Ok(r) if r.status().as_u16() == 404 => {
                    return Err(anyhow!(
                        "post não encontrado (apagado, privado ou id errado)"
                    ));
                }
                Ok(r) => {
                    return Err(anyhow!("HTTP {} em {}", r.status(), url));
                }
                Err(e) if attempt < TRIES => {
                    tokio::time::sleep(wait).await;
                    wait *= 2;
                    let _ = e;
                }
                Err(e) => return Err(e.into()),
            }
        }
        Err(anyhow!("não foi possível ler {}", url))
    }

    /// Segue os redirecionamentos de um link curto e devolve a URL final.
    pub async fn resolve(&self, url: &str) -> Result<String> {
        self.pace().await;
        self.requests.fetch_add(1, Ordering::Relaxed);
        let r = self.client.get(url).send().await?;
        Ok(r.url().to_string())

View on GitHub (pinned to 8600b91f42)