tonhowtf/omniget · error

Twitter API retornou HTTP

Error message

Twitter API retornou HTTP {}

What it means

The Twitter GraphQL endpoint answered with an unexpected non-success HTTP status that is not 403/429 (which map to token_expired) or 404 (which maps to 'Post not available'). The {} is the raw status code — usually 5xx server errors or transient auth/backend issues during request_tweet.

Solutions

  1. Log the full status and response body for diagnosis
  2. Retry with backoff on 5xx — usually transient
  3. Check whether the GraphQL query hash used by the library is still valid (400 may mean stale query ID)
  4. Fall back to the syndication API path

Example fix

// before
if !status.is_success() {
    return Err(anyhow!("Twitter API retornou HTTP {}", status));
}
// after
if status.is_server_error() {
    tracing::warn!("twitter 5xx ({}), retrying once", status);
    return self.request_tweet(tweet_id).await; // or add backoff
}
if !status.is_success() {
    return Err(anyhow!("Twitter API retornou HTTP {}: {}", 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") => {
        sleep(backoff).await;
        request_tweet(id).await // retry transient 5xx
    }
    other => other,
}

Prevention

When it happens

Trigger: Twitter GraphQL endpoint returns 401, 5xx server errors, 400 bad request, or unusual status codes outside the handled set.

Common situations: Twitter-wide outages (5xx); API contract changes returning 400; temporary infrastructure errors; new bot-detection status codes.

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

Appendix: source

Thrown at src-tauri/omniget-core/src/platforms/twitter.rs:306

        }

        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)