{"record":{"id":"79444c228facebc4","repo":"tonhowtf/omniget","slug":"fxtwitter-resposta-invalida","errorCode":null,"errorMessage":"FxTwitter: resposta invalida ({})","messagePattern":"FxTwitter: resposta invalida \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/x/fx.rs","lineNumber":46,"sourceCode":"\nasync fn get(path: &str, query: &[(&str, String)]) -> anyhow::Result<Value> {\n    let client = client()?;\n    let url = format!(\"{}/{}\", BASE, path.trim_start_matches('/'));\n    let mut req = client.get(&url);\n    let q: Vec<(&str, &str)> = query\n        .iter()\n        .filter(|(_, v)| !v.is_empty())\n        .map(|(k, v)| (*k, v.as_str()))\n        .collect();\n    if !q.is_empty() {\n        req = req.query(&q);\n    }\n    let resp = req.send().await?;\n    let status = resp.status();\n    let body: Value = resp\n        .json()\n        .await\n        .map_err(|e| anyhow!(\"FxTwitter: resposta invalida ({})\", e))?;\n    let code = body\n        .get(\"code\")\n        .and_then(|c| c.as_u64())\n        .unwrap_or(status.as_u16() as u64);\n    if code == 404 {\n        return Err(anyhow!(\"nao encontrado no X (ou o post e privado)\"));\n    }\n    if code == 401 {\n        return Err(anyhow!(\"post ou perfil privado\"));\n    }\n    if code == 429 {\n        return Err(anyhow!(\n            \"FxTwitter: limite de requisicoes atingido, tente de novo em instantes\"\n        ));\n    }\n    if code >= 400 {\n        let msg = body\n            .get(\"message\")","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/x/fx.rs#L28-L64","documentation":"fx.rs's get() calls the FxTwitter API and this error is raised when the HTTP response body cannot be deserialized as JSON. It wraps the serde error message plus the raw payload interpretation, meaning the upstream service returned non-JSON (HTML error page, empty body, gateway error).","triggerScenarios":"FxTwitter (or an intermediate proxy/CDN) responds with HTML (502/503 Cloudflare page), an empty body, or truncated output so resp.json() fails during any get()-backed call: status, thread, conversation, profile, profile_statuses, profile_media.","commonSituations":"FxTwitter outage or Cloudflare challenge page; corporate proxy stripping/rewriting the response; network device injecting a captive-portal page; FxTwitter deployment returning text/plain errors.","solutions":["Retry the request; transient upstream outages are the usual cause.","Log the response text and status before parsing to identify what actually came back.","Check FxTwitter service status / try an alternate API host (e.g. api.fxtwitter.com vs fixupx).","Fall back to a different X data source (the native X client) when FxTwitter is unavailable."],"exampleFix":"// before\nlet body: Value = resp.json().await\n    .map_err(|e| anyhow!(\"FxTwitter: resposta invalida ({})\", e))?;\n// after\nlet text = resp.text().await?;\nlet body: Value = serde_json::from_str(&text)\n    .map_err(|e| anyhow!(\"FxTwitter: resposta invalida ({}) corpo: {:.200}\", e, text))?;","handlingStrategy":"fallback","validationCode":null,"typeGuard":"fn is_json_content(headers: &reqwest::header::HeaderMap) -> bool {\n    headers.get(reqwest::header::CONTENT_TYPE)\n        .and_then(|v| v.to_str().ok())\n        .map_or(false, |v| v.contains(\"application/json\"))\n}","tryCatchPattern":"match fx::status(&id).await {\n    Ok(p) => p,\n    Err(e) if e.to_string().starts_with(\"FxTwitter: resposta invalida\") => {\n        eprintln!(\"FxTwitter fora do ar, usando cliente nativo\");\n        xclient::status(&id).await?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Check Content-Type is application/json before parsing","Keep the native X client as a documented fallback path","Alert on consecutive non-JSON responses (indicates upstream outage)","Use a short request timeout so proxy error pages fail fast"],"tags":["fxtwitter","json","network","http"],"backgroundTag":"invalid-json-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"}