{"record":{"id":"c68be8dac696c0ad","repo":"tonhowtf/omniget","slug":"twitter-api-retornou-http","errorCode":null,"errorMessage":"Twitter API retornou HTTP {}","messagePattern":"Twitter API retornou HTTP (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/platforms/twitter.rs","lineNumber":306,"sourceCode":"        }\n\n        let response = request.send().await?;\n\n        let status = response.status();\n        tracing::debug!(\"[twitter] graphql tweet_id={} status={}\", tweet_id, status);\n\n        if status == reqwest::StatusCode::FORBIDDEN\n            || status == reqwest::StatusCode::TOO_MANY_REQUESTS\n        {\n            return Err(anyhow!(\"token_expired\"));\n        }\n\n        if status == reqwest::StatusCode::NOT_FOUND {\n            return Err(anyhow!(\"Post not available\"));\n        }\n\n        if !status.is_success() {\n            return Err(anyhow!(\"Twitter API retornou HTTP {}\", status));\n        }\n\n        response.json().await.map_err(Into::into)\n    }\n\n    fn calculate_syndication_token(id: &str) -> String {\n        let num: f64 = id.parse().unwrap_or(0.0);\n        let raw = (num / 1e15) * std::f64::consts::PI;\n        let base36 = Self::f64_to_base36(raw);\n        base36\n            .replace('.', \"\")\n            .trim_start_matches('0')\n            .trim_end_matches('0')\n            .to_string()\n    }\n\n    fn f64_to_base36(value: f64) -> String {\n        if value == 0.0 {","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/platforms/twitter.rs#L288-L324","documentation":"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.","triggerScenarios":"Twitter GraphQL endpoint returns 401, 5xx server errors, 400 bad request, or unusual status codes outside the handled set.","commonSituations":"Twitter-wide outages (5xx); API contract changes returning 400; temporary infrastructure errors; new bot-detection status codes.","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"],"exampleFix":"// before\nif !status.is_success() {\n    return Err(anyhow!(\"Twitter API retornou HTTP {}\", status));\n}\n// after\nif status.is_server_error() {\n    tracing::warn!(\"twitter 5xx ({}), retrying once\", status);\n    return self.request_tweet(tweet_id).await; // or add backoff\n}\nif !status.is_success() {\n    return Err(anyhow!(\"Twitter API retornou HTTP {}: {}\", status, response.text().await.unwrap_or_default()));\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match request_tweet(id).await {\n    Err(e) if e.to_string().starts_with(\"Twitter API retornou HTTP 5\") => {\n        sleep(backoff).await;\n        request_tweet(id).await // retry transient 5xx\n    }\n    other => other,\n}","preventionTips":["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"],"tags":["twitter","http","graphql","api"],"backgroundTag":"http-error-response","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}