{"record":{"id":"b49bd86e56f0afd9","repo":"tonhowtf/omniget","slug":"x-http-client","errorCode":null,"errorMessage":"X: HTTP {} {}","messagePattern":"X: HTTP (.+?) (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/x/client.rs","lineNumber":495,"sourceCode":"                HeaderValue::from_str(v),\n            ) {\n                headers.insert(name, val);\n            }\n        }\n        let resp = self\n            .http\n            .post(url)\n            .headers(headers)\n            .json(body)\n            .send()\n            .await?;\n        if resp.status().as_u16() == 429 {\n            return Err(anyhow!(\"X_RATE_LIMIT:60\"));\n        }\n        if !resp.status().is_success() {\n            let st = resp.status();\n            let text = resp.text().await.unwrap_or_default();\n            return Err(anyhow!(\n                \"X: HTTP {} {}\",\n                st,\n                text.chars().take(300).collect::<String>()\n            ));\n        }\n        Ok(resp)\n    }\n\n    /// Pagina uma timeline: `on_page` recebe a resposta e devolve quantos\n    /// itens novos extraiu. Para no fim, no limite, em 3 paginas vazias, em\n    /// cursor repetido ou quando `job` for cancelado.\n    pub async fn paginate<F>(\n        &self,\n        op: &str,\n        mut variables: Value,\n        extra_features: Value,\n        limit: usize,\n        job: &str,","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/x/client.rs#L477-L513","documentation":"post_json_raw received a non-2xx, non-429 HTTP status from the raw JSON POST endpoint. The client returns the status plus the first 300 chars of the response body as a single error string ('X: HTTP <status> <body-snippet>') since raw endpoints have no structured error contract.","triggerScenarios":"POSTing to a Grok/raw endpoint with an expired session (401/403), a bad payload the endpoint rejects (400), a removed endpoint (404), or server-side failure (5xx).","commonSituations":"Cookies expired before a Grok request; request body schema changed upstream (X shipped a new add_response.json contract); endpoint URL typo; X outage returning 5xx HTML pages.","solutions":["Read the status and body snippet in the error to identify 401/403 (re-login) vs 400 (fix payload) vs 5xx (retry later)","Refresh the X session (re-login for fresh auth_token/ct0) if the status is 401/403","Compare the request body against X's current raw-endpoint contract and update fields","Confirm the URL is still valid (endpoint not removed/renamed)","Retry with backoff only for 5xx; 4xx responses will not succeed unchanged"],"exampleFix":"// before\nlet resp = client.post_json_raw(url, &body, &[]).await?;\n// after\nlet resp = match client.post_json_raw(url, &body, &[]).await {\n    Err(e) if e.to_string().contains(\"HTTP 401\") || e.to_string().contains(\"HTTP 403\") => { relogin()?; client.post_json_raw(url, &body, &[]).await? }\n    r => r?,\n};","handlingStrategy":"try-catch","validationCode":"// Rust: sanity-check URL and session before the raw POST\nurl::Url::parse(url)?; // fail fast on malformed endpoints\nif !client.authed() { relogin()?; }","typeGuard":null,"tryCatchPattern":"match client.post_json_raw(url, &body, &[]).await {\n    Err(e) => {\n        let s = e.to_string();\n        if s.contains(\"HTTP 401\") || s.contains(\"HTTP 403\") { relogin()?; client.post_json_raw(url, &body, &[]).await }\n        else if s.contains(\"HTTP 5\") { /* retry with backoff */ }\n        else { Err(e) }\n    }\n    r => r,\n}","preventionTips":["Keep the raw endpoint payload contract updated against X's current schema","Validate the URL and content-type before sending","Retry only 5xx; classify 4xx as payload/auth problems","Capture the 300-char body snippet in logs for diagnosis"],"tags":["x","http","grok","api-error"],"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"}