{"record":{"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/4d435abc281842f3cbee165b6cde739e001d3a25/actix-http/src/h1/chunked.rs#L145-L181","documentation":"Raised in read_body_lf (chunked.rs:163) when, after the CR following a chunk body, the next byte is not '\\n'. Together with read_body_cr it enforces the CRLF that must terminate each chunk; a missing LF means the framing is broken and the parser rejects the stream.","triggerScenarios":"A chunk body is followed by CR then a non-LF byte (e.g. CR followed by more data or a digit of the next size with no LF). read_body_lf only accepts '\\n', transitioning back to the Size state on success.","commonSituations":"Inconsistent line endings; corrupt stream; proxy stripping LF characters; client bug emitting only CR after chunk data.","solutions":["Terminate every chunk body with a full CRLF (\\r\\n) before the next chunk-size line.","Use a compliant HTTP serializer library.","Inspect proxy CRLF handling if errors appear only behind a reverse proxy."],"exampleFix":"// before\n\"4\\r\\nabcd\\r0\\r\\n\\r\\n\"\n// after\n\"4\\r\\nabcd\\r\\n0\\r\\n\\r\\n\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match payload.next().await {\n    Some(Err(PayloadError::Io(e))) if e.kind() == io::ErrorKind::InvalidInput =>\n        return HttpResponse::BadRequest().finish(), // chunk body LF missing\n    _ => { /* ... */ }\n}","preventionTips":["Terminate chunk bodies with full CRLF.","Avoid bare-CR line endings in chunked bodies.","Verify proxy CRLF handling."],"tags":["http","chunked-encoding","actix-http","protocol"],"backgroundTag":null,"analyzedSha":"4d435abc281842f3cbee165b6cde739e001d3a25","analyzedAt":"2026-08-09T01:01:40.926Z","contentChangedAt":"2026-08-09T01:01:40.926Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}