{"record":{"id":"92f2820caba0adeb","repo":"tonhowtf/omniget","slug":"grok","errorCode":null,"errorMessage":"{} / {}","messagePattern":"\\{\\} / \\{\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/x/grok.rs","lineNumber":334,"sourceCode":"    });\n    let uuid = uuid::Uuid::new_v4().simple().to_string();\n    let extra = [\n        (\"x-client-uuid\", uuid.as_str()),\n        (\"Referer\", \"https://x.com/i/grok\"),\n    ];\n    let resp = match client\n        .post_json_raw(\"https://api.x.com/2/grok/add_response.json\", &body, &extra)\n        .await\n    {\n        Ok(r) => r,\n        Err(first) => client\n            .post_json_raw(\n                \"https://x.com/i/api/2/grok/add_response.json\",\n                &body,\n                &extra,\n            )\n            .await\n            .map_err(|e| anyhow!(\"{} / {}\", first, e))?,\n    };\n    let raw = resp.text().await?;\n    let mut text = String::new();\n    let mut citations: Vec<Citation> = Vec::new();\n    for line in raw.lines() {\n        let Ok(v) = serde_json::from_str::<Value>(line.trim()) else {\n            continue;\n        };\n        let Some(r) = v.get(\"result\") else { continue };\n        if let Some(m) = r.get(\"message\").and_then(|m| m.as_str()) {\n            if r.get(\"sender\")\n                .and_then(|s| s.as_str())\n                .map(|s| s != \"USER\")\n                .unwrap_or(true)\n            {\n                text.push_str(m);\n            }\n        }","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/x/grok.rs#L316-L352","documentation":"ask_x posts the chat to https://api.x.com/2/grok/add_response.json and, if that fails, retries on https://x.com/i/api/2/grok/add_response.json. When BOTH hosts fail, the two transport errors are joined with \" / \" into a single error. This indicates the request to X's Grok endpoint failed at the HTTP layer on both mirrors, not that Grok rejected the payload.","triggerScenarios":"Both post_json_raw calls return Err: network/DNS failure, proxy issues, 401/403/429 responses treated as errors by the client, missing x-client-uuid/Referer headers rejected by X, or X blocking the request (anti-bot).","commonSituations":"No internet or blocked access to x.com; stale session cookies causing 403 on add_response; X rate limiting Grok requests; corporate proxy blocking api.x.com; X changing endpoint paths so both hosts 404.","solutions":["Read both halves of the error: the first is the api.x.com failure, the second the x.com/i/api failure — fix the root cause they share.","Refresh the X session/login (most common cause is 401/403 from stale cookies).","Check network/proxy connectivity to x.com (curl the endpoint).","If rate-limited (429), wait and retry with backoff.","Verify X has not moved the add_response endpoint; update the URL constants if so."],"exampleFix":"// before\n// both hosts failing with 403 from expired cookies\nErr(\"request failed: 403 Forbidden / request failed: 403 Forbidden\")\n// after\n// re-login to refresh cookies, then retry\nclient.require_login()?; // or full re-auth flow before ask_x","handlingStrategy":"retry","validationCode":"// preflight connectivity to X before issuing the chat request\nif reqwest::get(\"https://x.com\").await.is_err() { return Err(\"no connectivity to x.com\"); }","typeGuard":null,"tryCatchPattern":"match grok::ask(req).await {\n    Ok(a) => use_answer(a),\n    Err(e) if e.to_string().contains(\" / \") => {\n        // both mirrors failed; backoff then retry once\n        tokio::time::sleep(Duration::from_secs(5)).await;\n        grok::ask(req).await\n    }\n    Err(e) => log_error(e),\n}","preventionTips":["Ensure outbound network/proxy access to both api.x.com and x.com","Refresh session cookies when 401/403 errors appear","Back off on 429 instead of hammering both mirrors","Watch for X endpoint moves and update the mirror URLs"],"tags":["network","http","x","retry"],"backgroundTag":"http-request-failed","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"}