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
- Log the full status and response body for diagnosis
- Retry with backoff on 5xx — usually transient
- Check whether the GraphQL query hash used by the library is still valid (400 may mean stale query ID)
- 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
- Retry only 5xx and 429 with backoff; fail fast on others
- Log response bodies for unhandled statuses
- Keep the GraphQL query hash current (stale hashes cause 400s)
- Monitor Twitter status pages for outages
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
- YouTube não retornou URL
- Twitch GQL respondeu HTTP
- Twitter API retornou HTTP
- ERR_TOO_MANY_ATTACHMENTS
- HLS nao e suportado neste navegador
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)