{"id":"86bc4326863da986","repo":"actix/actix-web","slug":"invalid-chunk-body-lf","errorCode":null,"errorMessage":"Invalid chunk body LF","messagePattern":"Invalid chunk body LF","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"actix-http/src/h1/chunked.rs","lineNumber":163,"sourceCode":"            } else {\n                Poll::Ready(Ok(ChunkedState::BodyCr))\n            }\n        }\n    }\n\n    fn read_body_cr(rdr: &mut BytesMut) -> Poll<Result<ChunkedState, io::Error>> {\n        match byte!(rdr) {\n            b'\\r' => Poll::Ready(Ok(ChunkedState::BodyLf)),\n            _ => Poll::Ready(Err(io::Error::new(\n                io::ErrorKind::InvalidInput,\n                \"Invalid chunk body CR\",\n            ))),\n        }\n    }\n    fn read_body_lf(rdr: &mut BytesMut) -> Poll<Result<ChunkedState, io::Error>> {\n        match byte!(rdr) {\n            b'\\n' => Poll::Ready(Ok(ChunkedState::Size)),\n            _ => Poll::Ready(Err(io::Error::new(\n                io::ErrorKind::InvalidInput,\n                \"Invalid chunk body LF\",\n            ))),\n        }\n    }\n    fn read_end_cr(rdr: &mut BytesMut) -> Poll<Result<ChunkedState, io::Error>> {\n        match byte!(rdr) {\n            b'\\r' => Poll::Ready(Ok(ChunkedState::EndLf)),\n            _ => Poll::Ready(Err(io::Error::new(\n                io::ErrorKind::InvalidInput,\n                \"Invalid chunk end CR\",\n            ))),\n        }\n    }\n    fn read_end_lf(rdr: &mut BytesMut) -> Poll<Result<ChunkedState, io::Error>> {\n        match byte!(rdr) {\n            b'\\n' => Poll::Ready(Ok(ChunkedState::End)),\n            _ => Poll::Ready(Err(io::Error::new(","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/actix/actix-web/blob/937960ca67f20e14ffe2a075bf6d4593502be12c/actix-http/src/h1/chunked.rs#L145-L181","documentation":"io::Error(InvalidInput, \"Invalid chunk body LF\") (chunked.rs:163-166) is returned by read_body_lf when the byte after the chunk-body CR is not an LF. The parser reached BodyLf by consuming the CR terminator; anything other than '\\n' breaks the CRLF that must follow each chunk body.","triggerScenarios":"A chunk body is terminated with CR plus a non-LF byte, e.g. the encoder wrote '\\r.' instead of '\\r\\n'. read_body_cr accepted the CR and advanced to BodyLf, which then sees the stray byte.","commonSituations":"Lone-CR terminators from a broken encoder, or proxy corruption of the line ending.","solutions":["Ensure each chunk body ends with a strict CRLF.","Capture the raw stream around the chunk boundary.","Prefer Content-Length for fixed-size bodies."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Lone-CR terminator -> treat as bad request.\nuse actix_http::error::PayloadError;\nif matches!(payload.next().await, Some(Err(PayloadError::Io(e))) if e.kind() == io::ErrorKind::InvalidInput) {\n    return HttpResponse::BadRequest().finish();\n}","preventionTips":["Terminate every chunk body with strict CRLF.","Capture wire bytes at the boundary when debugging.","Use a vetted encoder library."],"tags":["http","transfer-encoding","chunked","actix-http","protocol"],"analyzedSha":"937960ca67f20e14ffe2a075bf6d4593502be12c","analyzedAt":"2026-08-06T01:15:46.978Z","schemaVersion":2}