{"record":{"id":"245c9f0bee8f4d10","repo":"vectordotdev/vector","slug":"invaliddata","errorCode":"InvalidData","errorMessage":"Unable to decode message len as number","messagePattern":"Unable to decode message len as number","errorType":"exception","errorClass":"LinesCodecError::Io","httpStatus":null,"severity":"error","filePath":"lib/codecs/src/decoding/framing/octet_counting.rs","lineNumber":150,"sourceCode":"            (State::NotDiscarding, _, Some(space_pos)) if space_pos < self.other.max_length() => {\n                // Everything looks good.\n                //\n                // We aren't discarding, we have a space that is not beyond our\n                // maximum length. Attempt to parse the bytes as a number which\n                // will hopefully give us a sensible length for our message.\n                let len: usize = match std::str::from_utf8(&src[..space_pos])\n                    .map_err(|_| ())\n                    .and_then(|num| num.parse().map_err(|_| ()))\n                {\n                    Ok(len) => len,\n                    Err(_) => {\n                        // It was not a sensible number.\n                        //\n                        // Advance the buffer past the erroneous bytes to\n                        // prevent us getting stuck in an infinite loop.\n                        src.advance(space_pos + 1);\n                        self.octet_decoding = None;\n                        return Err(LinesCodecError::Io(io::Error::new(\n                            io::ErrorKind::InvalidData,\n                            \"Unable to decode message len as number\",\n                        )));\n                    }\n                };\n\n                let from = space_pos + 1;\n                let to = from + len;\n\n                if len > self.other.max_length() {\n                    // The length is greater than we want.\n                    //\n                    // We need to discard the entire message.\n                    self.octet_decoding = Some(State::Discarding(len));\n                    src.advance(space_pos + 1);\n\n                    Ok(None)\n                } else if let Some(msg) = src.get(from..to) {","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/lib/codecs/src/decoding/framing/octet_counting.rs#L132-L168","documentation":"The octet-counting framer (RFC 6587 style, `\"<digits> <payload>\"`) parses the ASCII digits before the space as the message length. If those bytes are not valid UTF-8 digits that parse as a `usize`, it advances past them (so decoding can make progress) and returns an `InvalidData` io error wrapped in `LinesCodecError::Io`. The framing method is selected via `framing.method = \"octet_counting\"` on the source's decoding config.","triggerScenarios":"Data arriving on a port/framing set to octet_counting that does not start with `<len> ` — e.g. syslog sent without the octet-counting prefix (newline-delimited BSD syslog), a leading newline/space, a negative or oversized number, or a length containing separators like commas.","commonSituations":"Sender set to `syslog.frame_type = \"non_transparent_framing\"` (newline) while Vector expects octet counting; sending plain text lines to an octet_counting input; non-ASCII bytes at datagram start (binary protocols on a reused port).","solutions":["Align framing on both ends: either enable octet counting on the sender (rsyslog `omfwd` with `TCP_Framing=\"octet-counted\"`) or switch Vector's `framing.method` to `newline_delimited`/`character_delimited`.","If input is genuinely mixed, split it across two sources on separate ports with the correct framing each.","Capture a few payloads to confirm whether the `<len> ` prefix is present at all before changing config."],"exampleFix":"# before\ndecoding:\n  framing:\n    method: octet_counting\n# sender emits plain newline-delimited syslog\n\n# after\ndecoding:\n  framing:\n    method: newline_delimited","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match decoder.decode(&mut src).await {\n    Ok(Some(frame)) => { /* handle */ }\n    Ok(None) => {}\n    Err(LinesCodecError::Io(ref e)) if e.kind() == io::ErrorKind::InvalidData => {\n        // framing prefix was not a number: bytes were skipped, keep reading\n        warn!(error = %e, \"skipping non-octet-counted frame\");\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Lock framing choice in the sender and Vector config to the same mode; document it next to the port.","For syslog senders, prefer octet counting end-to-end (rsyslog `TCP_Framing=\"octet-counted\"`).","The decoder advances past bad bytes, so logging at warn and continuing is safe."],"tags":["framing","octet-counting","syslog","decode","vector"],"backgroundTag":"invalid-message-length","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}