{"record":{"id":"2a7137b15c01f1d1","repo":"affaan-m/ECC","slug":"missing-http-path","errorCode":null,"errorMessage":"Missing HTTP path","messagePattern":"Missing HTTP path","errorType":"validation","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/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/main.rs#L4205-L4241","documentation":"This error is thrown while parsing a raw HTTP request from its textual representation. The parser splits the request into parts and expects at least a method and a path on the request line; when the iterator is exhausted before the path token, it reports 'Missing HTTP path'. It guards against malformed or truncated request input.","triggerScenarios":"Parsing an HTTP request string whose request line contains only a method (e.g. 'GET' with no path or trailing CRLF), or passing an empty/truncated request to the parser.","commonSituations":"Feeding hand-crafted curl-like strings to an internal HTTP parser, truncated logs replayed as requests, or clients sending a bare method without a path (common in raw socket tests).","solutions":["Verify the raw request includes a full request line: METHOD /path HTTP/1.1 followed by headers and CRLF.","Check that the input buffer was not truncated before parsing (read the full request before splitting).","Reject empty input early with a clearer client-facing message instead of letting the parser fail.","Validate the request-line token count before calling next() twice."],"exampleFix":"// before\nlet raw = \"GET\";\nparse_request(raw)?; // panics into Missing HTTP path\n// after\nlet raw = \"GET /health HTTP/1.1\\r\\nHost: localhost\\r\\n\\r\\n\";\nif raw.split_whitespace().count() < 2 {\n    anyhow::bail!(\"request line must include method and path\");\n}\nparse_request(raw)?;","handlingStrategy":"validation","validationCode":"fn has_request_line(raw: &str) -> bool {\n    let mut parts = raw.split_whitespace();\n    parts.next().map(|_| parts.next().is_some()).unwrap_or(false)\n}\n// call: if !has_request_line(raw) { bail!(\"malformed request line\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include a full request line (method, path, version) in raw request fixtures","Read the complete request before parsing to avoid truncation","Add a unit test for empty and single-token request lines","Reject empty payloads before invoking the parser"],"tags":["http","parsing","request-validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}