{"record":{"id":"bea08c039da5f916","repo":"actix/actix-web","slug":"invalid-chunk-end-lf","errorCode":null,"errorMessage":"Invalid chunk end LF","messagePattern":"Invalid chunk end LF","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"actix-http/src/h1/chunked.rs","lineNumber":181,"sourceCode":"            _ => 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(\n                io::ErrorKind::InvalidInput,\n                \"Invalid chunk end LF\",\n            ))),\n        }\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use actix_codec::Decoder as _;\n    use bytes::{Bytes, BytesMut};\n    use http::Method;\n\n    use crate::{\n        error::ParseError,\n        h1::decoder::{MessageDecoder, PayloadItem},\n        HttpMessage as _, Request,\n    };","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/actix/actix-web/blob/4d435abc281842f3cbee165b6cde739e001d3a25/actix-http/src/h1/chunked.rs#L163-L199","documentation":"Raised in read_end_lf (chunked.rs:181) when, after the CR of the trailer terminator, the next byte is not '\\n'. It is the final check of the chunked state machine (transitioning to ChunkedState::End); a missing LF means the body terminator is malformed and the stream is rejected as PayloadError::Io.","triggerScenarios":"The end sequence is \"0\\r\\n\\r\" but the final '\\n' is missing or replaced - e.g. the connection closes after a lone CR, or a non-LF byte follows.","commonSituations":"Truncated final chunk terminator; proxy stripping the last LF; client bug; connection drop mid-terminator.","solutions":["Ensure the body ends with the complete \"0\\r\\n\\r\\n\" sequence.","Use a compliant HTTP client library for chunked uploads.","Verify proxies forward the complete terminator without truncation."],"exampleFix":"// before\n\"0\\r\\n\\r\"\n// after\n\"0\\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(), // missing LF after last chunk CR\n    _ => { /* ... */ }\n}","preventionTips":["End chunked uploads with the complete \"0\\r\\n\\r\\n\" terminator.","Use a compliant HTTP client library.","Ensure proxies forward the full terminator."],"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"}