{"record":{"id":"2a7137b15c01f1d1","repo":"affaan-m/ECC","slug":"missing-http-path","errorCode":null,"errorMessage":"Missing HTTP path","messagePattern":"Missing HTTP path","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/main.rs","lineNumber":4223,"sourceCode":"            anyhow::bail!(\"HTTP request headers too large\");\n        }\n    };\n\n    let header_text = String::from_utf8(buffer[..header_end].to_vec())\n        .context(\"HTTP request headers were not valid UTF-8\")?;\n    let mut lines = header_text.split(\"\\r\\n\");\n    let request_line = lines\n        .next()\n        .filter(|line| !line.trim().is_empty())\n        .ok_or_else(|| anyhow::anyhow!(\"Missing HTTP request line\"))?;\n    let mut request_parts = request_line.split_whitespace();\n    let method = request_parts\n        .next()\n        .ok_or_else(|| anyhow::anyhow!(\"Missing HTTP method\"))?\n        .to_string();\n    let path = request_parts\n        .next()\n        .ok_or_else(|| anyhow::anyhow!(\"Missing HTTP path\"))?\n        .to_string();\n\n    let mut headers = BTreeMap::new();\n    for line in lines {\n        if line.is_empty() {\n            break;\n        }\n        if let Some((key, value)) = line.split_once(':') {\n            headers.insert(key.trim().to_ascii_lowercase(), value.trim().to_string());\n        }\n    }\n\n    let content_length = headers\n        .get(\"content-length\")\n        .and_then(|value| value.parse::<usize>().ok())\n        .unwrap_or(0);\n    let mut body = buffer[header_end..].to_vec();\n    while body.len() < content_length {","sourceCodeStart":4205,"sourceCodeEnd":4241,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/ecc2/src/main.rs#L4205-L4241","documentation":"Thrown by read_http_request when the request line contains a method token (e.g. 'GET') but no second whitespace-delimited token for the request path. The parser needs METHOD PATH VERSION; without a path it cannot route the request and bails.","triggerScenarios":"A client sends a request line like 'GET\\r\\n' (method only), 'POST HTTP/1.1' (method plus protocol but no path), or any line whose whitespace split produces exactly one token. Common with minimal hand-rolled HTTP clients, some monitoring probes, or telnet sessions that type only the method.","commonSituations":"Telnet into the HTTP port and typing 'GET' then enter; a CLI tool that builds the request line by string concatenation and forgets the path; a health check configured to send only the method.","solutions":["Fix the client to send a complete request line: 'GET / HTTP/1.1\\r\\n'.","If you do not control the client, catch this parse error at the accept loop and respond with HTTP 400.","Add a unit test that asserts read_http_request rejects 'GET\\r\\n\\r\\n' so the behavior is documented."],"exampleFix":"// before\nlet req = read_http_request(&mut stream)?;\n\n// after\nlet req = match read_http_request(&mut stream) {\n    Ok(r) => r,\n    Err(e) => {\n        log::warn!(\"rejecting malformed request: {e:#}\");\n        let _ = write_http_response(&mut stream, 400, \"text/plain\", \"bad request\");\n        continue;\n    }\n};","handlingStrategy":"validation","validationCode":"fn request_line_has_path(line: &str) -> bool {\n    line.trim().split_whitespace().count() >= 2\n}","typeGuard":null,"tryCatchPattern":"match read_http_request(&mut stream) {\n    Ok(req) => handle(req),\n    Err(e) => {\n        log::warn!(\"malformed request line: {e:#}\");\n        let _ = write_http_response(&mut stream, 400, \"text/plain\", \"bad request\");\n    }\n}","preventionTips":["Validate client request lines before sending if you control the client.","Keep malformed-request handling in the accept loop so one bad client does not affect others."],"tags":["http","network","input-validation","tcp-server"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}