{"record":{"id":"529374c039907f13","repo":"Kuberwastaken/claurst","slug":"invalid-http-request","errorCode":null,"errorMessage":"Invalid HTTP request","messagePattern":"Invalid HTTP request","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-rust/crates/cli/src/codex_oauth_flow.rs","lineNumber":130,"sourceCode":"async fn wait_for_callback(listener: TcpListener) -> anyhow::Result<(String, String)> {\r\n    use tokio::io::AsyncWriteExt;\r\n\r\n    let (mut socket, _) = tokio::time::timeout(\r\n        std::time::Duration::from_secs(300), // 5 minute timeout\r\n        listener.accept(),\r\n    )\r\n    .await\r\n    .map_err(|_| anyhow!(\"OAuth callback timeout (5 minutes)\"))?\r\n    .map_err(|e| anyhow!(\"Failed to accept connection: {}\", e))?;\r\n\r\n    let mut reader = BufReader::new(&mut socket);\r\n    let mut request_line = String::new();\r\n    reader.read_line(&mut request_line).await?;\r\n\r\n    // Parse \"GET /auth/callback?code=...&state=... HTTP/1.1\"\r\n    let parts: Vec<&str> = request_line.split_whitespace().collect();\r\n    if parts.len() < 2 {\r\n        bail!(\"Invalid HTTP request\");\r\n    }\r\n\r\n    let path = parts[1];\r\n    let query_start = path.find('?').ok_or_else(|| anyhow!(\"No query string in callback\"))?;\r\n    let query = &path[query_start + 1..];\r\n\r\n    let mut code = String::new();\r\n    let mut state = String::new();\r\n    let mut error = String::new();\r\n\r\n    for param in query.split('&') {\r\n        let kv: Vec<&str> = param.splitn(2, '=').collect();\r\n        if kv.len() == 2 {\r\n            match kv[0] {\r\n                \"code\" => code = urlencoding::decode(kv[1])?.to_string(),\r\n                \"state\" => state = urlencoding::decode(kv[1])?.to_string(),\r\n                \"error\" => error = urlencoding::decode(kv[1])?.to_string(),\r\n                \"error_description\" => error = urlencoding::decode(kv[1])?.to_string(),\r","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/cli/src/codex_oauth_flow.rs#L112-L148","documentation":"The loopback HTTP server accepted the browser's OAuth callback connection but the first request line could not be parsed as `GET /auth/callback?...`. Means the client sent a malformed or non-HTTP request (e.g. a health probe, prefetch, or telnet-style connection) to the local callback port.","triggerScenarios":"Thrown at src-rust/crates/cli/src/codex_oauth_flow.rs:130 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the login flow; the browser usually sends a well-formed request on the next attempt","Ensure nothing else (proxy, antivirus, another app) is hitting 127.0.0.1 on the callback port","If it persists, capture the raw request line to identify what client is connecting"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}