{"id":"98dd0eb049f5a943","repo":"apache/kafka","slug":"version-d-is-unsupported","errorCode":null,"errorMessage":"Version %d is unsupported","messagePattern":"Version (.+?) is unsupported","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/common/compress/Lz4BlockOutputStream.java","lineNumber":321,"sourceCode":"                           blockChecksum,\n                           blockIndependence,\n                           version);\n        }\n\n        public byte toByte() {\n            return (byte) (((reserved & 3) << 0) | ((contentChecksum & 1) << 2)\n                    | ((contentSize & 1) << 3) | ((blockChecksum & 1) << 4) | ((blockIndependence & 1) << 5) | ((version & 3) << 6));\n        }\n\n        private void validate() {\n            if (reserved != 0) {\n                throw new RuntimeException(\"Reserved bits must be 0\");\n            }\n            if (blockIndependence != 1) {\n                throw new RuntimeException(\"Dependent block stream is unsupported\");\n            }\n            if (version != VERSION) {\n                throw new RuntimeException(String.format(\"Version %d is unsupported\", version));\n            }\n        }\n\n        public boolean isContentChecksumSet() {\n            return contentChecksum == 1;\n        }\n\n        public boolean isContentSizeSet() {\n            return contentSize == 1;\n        }\n\n        public boolean isBlockChecksumSet() {\n            return blockChecksum == 1;\n        }\n\n        public int getVersion() {\n            return version;\n        }","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/apache/kafka/blob/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/clients/src/main/java/org/apache/kafka/common/compress/Lz4BlockOutputStream.java#L303-L339","documentation":"Thrown by FLG.validate() when the 2-bit Version field (bits 6-7 of FLG) is not equal to 1 (FLG.VERSION). The LZ4 frame format defines version 1 as the only currently valid value; any other version means the frame was written by an incompatible (typically future) LZ4 revision this code cannot parse.","triggerScenarios":"FLG.fromByte(b) where (b>>>6)&3 != 1, during readHeader() (line 127). The %d in the message is the offending version number. Reachable when a future LZ4 frame format (version 2+) is fed to this implementation, or when the FLG byte is corrupted.","commonSituations":"Forward-incompatibility: a newer LZ4 specification ships version 2 frames and an older Kafka client tries to read them; bit-rot in the FLG byte; a non-Kafka producer that increments the version field; test fixtures with malformed FLG bytes. Not seen in normal Kafka-to-Kafka traffic because Kafka always writes version 1.","solutions":["Identify the producer of the frame and re-emit using LZ4 frame version 1 (or upgrade the Kafka client to a version that supports the new frame format, if one exists).","Inspect the raw FLG byte at the failing offset to confirm whether the version bits are genuinely set or whether the byte is corrupted (e.g. off-by-one read pointer).","If reading external LZ4 data, route it through an LZ4 library that supports the produced version instead of Kafka's partial-frame implementation.","Re-fetch from another replica to rule out transmission corruption."],"exampleFix":"// before: a future/external LZ4 encoder writes version 2 frames\n// (Kafka reader throws: \"Version 2 is unsupported\")\n\n// after: emit version-1 LZ4 frames (Kafka's default) so FLG.VERSION matches\nCompressionType compression = CompressionType.LZ4; // always writes FLG version 1","handlingStrategy":"try-catch","validationCode":"// FLG.version is bits 6-7; only version 1 is accepted.\nbyte flgByte = frameBuf.get(flgOffset);\nint version = (flgByte >>> 6) & 0x03;\nif (version != 1) {\n    throw new IOException(\"Refusing LZ4 frame: unsupported version \" + version);\n}","typeGuard":"null","tryCatchPattern":"try {\n    try (Lz4BlockInputStream in = new Lz4BlockInputStream(payload, BufferSupplier.NO_CACHING, false)) {\n        // consume\n    }\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"is unsupported\") && e.getMessage().startsWith(\"Version\")) {\n        // Frame was produced by an LZ4 implementation using a future/incompatible frame version.\n        log.warn(\"Unsupported LZ4 frame version on {}, skipping\", tp);\n        return;\n    }\n    throw e;\n}","preventionTips":["Pin LZ4 frame compatibility by pinning Kafka client versions across producers and consumers — version 1 is the only frame version Kafka emits.","For cross-system LZ4 payloads, transcode through Kafka producer compression so the frame version is always Kafka-valid.","Treat 'unsupported version' as a forward-incompatibility signal; do not retry against the same payload."],"tags":["compression","lz4","frame-format","validation","version","kafka-clients"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}