tonhowtf/omniget · error · anyhow::Error

Twitter API retornou HTTP

Error message

Twitter API retornou HTTP {}

What it means

request_tweet raises this formatted error when the GraphQL response status is neither 403/429, 404, nor a success — i.e. any other non-2xx HTTP status (5xx, 401, redirects, etc.). It surfaces the raw status code for diagnosis.

Solutions

  1. Read the logged status: 5xx → retry with backoff; 400 → refresh the GraphQL query_id/features from the current twitter.com bundle
  2. Retry transient 5xx/timeout errors a limited number of times
  3. Keep the hardcoded query_id and feature flags up to date — Twitter rotates them regularly
  4. Check for proxy/firewall interference if unexpected statuses (30x/40x) appear consistently

Example fix

// before
if !status.is_success() {
    return Err(anyhow!("Twitter API retornou HTTP {}", status));
}
// after
if !status.is_success() {
    return Err(anyhow!("Twitter API retornou HTTP {} body={}", status,
        response.text().await.unwrap_or_default()));
}
Defensive patterns

Strategy: retry

Try / catch

match request_tweet(id).await {
    Err(e) if e.to_string().starts_with("Twitter API retornou HTTP 5") => {
        tokio::time::sleep(backoff).await;
        request_tweet(id).await
    }
    Err(e) if e.to_string().contains("400") => {
        platform.refresh_query_id().await?;
        request_tweet(id).await
    }
    other => other,
}

Prevention

When it happens

Trigger: Twitter's GraphQL endpoint returns e.g. 401 Unauthorized, 500/502/503/504 server errors, 301/302 redirects, or 400 Bad Request for a malformed variables/query_id combination.

Common situations: Outdated GraphQL query_id after a Twitter deploy (400); Twitter incident causing 5xx; missing/expired headers yielding 401; corporate proxy injecting its own error status.

Related errors


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

Appendix: source

Thrown at src-tauri/src/platforms/twitter/mod.rs:372

        }

        let response = request.send().await?;

        let status = response.status();
        tracing::debug!("[twitter] graphql tweet_id={} status={}", tweet_id, status);

        if status == reqwest::StatusCode::FORBIDDEN
            || status == reqwest::StatusCode::TOO_MANY_REQUESTS
        {
            return Err(anyhow!("token_expired"));
        }

        if status == reqwest::StatusCode::NOT_FOUND {
            return Err(anyhow!("Post not available"));
        }

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

        response.json().await.map_err(Into::into)
    }

    fn calculate_syndication_token(id: &str) -> String {
        let num: f64 = id.parse().unwrap_or(0.0);
        let raw = (num / 1e15) * std::f64::consts::PI;
        let base36 = Self::f64_to_base36(raw);
        base36
            .replace('.', "")
            .trim_start_matches('0')
            .trim_end_matches('0')
            .to_string()
    }

    fn f64_to_base36(value: f64) -> String {
        if value == 0.0 {

View on GitHub (pinned to 8600b91f42)