{"record":{"id":"294cf9a4100cf4d3","repo":"vectordotdev/vector","slug":"received-chunk-with-message-id-message-id-and-se","errorCode":null,"errorMessage":"Received chunk with message id {message_id} and sequence number {sequence_number} has an invalid total chunks value of {total_chunks}. It must be between 1 and {GELF_MAX_TOTAL_CHUNKS}.","messagePattern":"Received chunk with message id (.+?) and sequence number (.+?) has an invalid total chunks value of (.+?)\\. It must be between 1 and (.+?)\\.","errorType":"error_code","errorClass":"ChunkedGelfDecoderError::InvalidTotalChunks","httpStatus":null,"severity":"error","filePath":"lib/codecs/src/decoding/framing/chunked_gelf.rs","lineNumber":418,"sourceCode":"        // | 64 bits    | 8 bits          | 8 bits       | remaining bits       |\n        // +------------+-----------------+--------------+----------------------+\n        //\n        // As this codec is oriented for UDP, the chunks (datagrams) are not guaranteed to be received in order,\n        // nor to be received at all. So, we have to store the chunks in a buffer (state field) until we receive\n        // all the chunks of a message. When we receive all the chunks of a message, we can concatenate them\n        // and return the complete payload.\n\n        // We need 10 bytes to read the message id, sequence number and total chunks\n        ensure!(\n            chunk.remaining() >= 10,\n            InvalidChunkHeaderSnafu { header: chunk }\n        );\n\n        let message_id = chunk.get_u64();\n        let sequence_number = chunk.get_u8();\n        let total_chunks = chunk.get_u8();\n\n        ensure!(\n            total_chunks > 0 && total_chunks <= GELF_MAX_TOTAL_CHUNKS,\n            InvalidTotalChunksSnafu {\n                message_id,\n                sequence_number,\n                total_chunks\n            }\n        );\n\n        ensure!(\n            sequence_number < total_chunks,\n            InvalidSequenceNumberSnafu {\n                message_id,\n                sequence_number,\n                total_chunks\n            }\n        );\n\n        let chunk_len = chunk.len();","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/codecs/src/decoding/framing/chunked_gelf.rs#L400-L436","documentation":"In the GELF chunking protocol, byte 9 of the chunk header is the total number of chunks for the message and must be between 1 and `GELF_MAX_TOTAL_CHUNKS` (128). `decode_chunk` validates this after reading the header and rejects chunks whose total is 0 or exceeds the max, embedding the message id, sequence number, and offending value in the error. A zero or oversized total cannot correspond to a valid GELF chunked message.","triggerScenarios":"A datagram passes the 10-byte length check but its third header byte (`get_u8` for total_chunks) is 0 or greater than 128 — i.e. malformed data from the sender or bit corruption in transit.","commonSituations":"A buggy custom client writing total chunks as a 16-bit or 0-based count; corrupted UDP payload in flight; a non-GELF protocol incidentally producing a 10+ byte datagram that lands on the chunked GELF listener.","solutions":["Fix the sender so the total chunks byte is a 1-based count between 1 and 128, as per the GELF chunking spec.","Verify which client produces these packets (message id in the error identifies the stream) and update or fix its chunking code.","Confirm chunks aren't being corrupted in transit — recompute/compare on a packet capture.","Ensure only GELF-speaking senders target this UDP port."],"exampleFix":"// before: 0-based total\nchunk[9] = total_chunks as u8;            // 0 for single chunk -> error\n\n// after: 1-based count per GELF spec\nchunk[9] = total_chunks.max(1) as u8;     // e.g. 1 for a single chunk","handlingStrategy":"validation","validationCode":"// sender-side guard\nlet total_chunks = parts.len() as u8;\nassert!(total_chunks >= 1 && total_chunks <= 128,\n        \"GELF total chunks must be 1..=128, got {total_chunks}\");\nchunk_header[9] = total_chunks;","typeGuard":null,"tryCatchPattern":"match framing.decode(&datagram) {\n    Err(e) if e.to_string().contains(\"invalid total chunks\") => {\n        error!(\"malformed GELF sender detected: {e}\");\n    }\n    other => { /* handle normally */ }\n}","preventionTips":["Write total chunks as a 1-based count capped at 128 (GELF spec) in header byte 9.","Unit-test your chunker against edge cases (1 chunk, 128 chunks).","Pin down which client emits bad totals using the message id in the error."],"tags":["gelf","udp","codecs","framing","rust"],"backgroundTag":"value-out-of-range","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}