apache/kafka · error · RuntimeException

Version %d is unsupported

Error message

Version %d is unsupported

What it means

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.

Source

Thrown at clients/src/main/java/org/apache/kafka/common/compress/Lz4BlockOutputStream.java:321

                           blockChecksum,
                           blockIndependence,
                           version);
        }

        public byte toByte() {
            return (byte) (((reserved & 3) << 0) | ((contentChecksum & 1) << 2)
                    | ((contentSize & 1) << 3) | ((blockChecksum & 1) << 4) | ((blockIndependence & 1) << 5) | ((version & 3) << 6));
        }

        private void validate() {
            if (reserved != 0) {
                throw new RuntimeException("Reserved bits must be 0");
            }
            if (blockIndependence != 1) {
                throw new RuntimeException("Dependent block stream is unsupported");
            }
            if (version != VERSION) {
                throw new RuntimeException(String.format("Version %d is unsupported", version));
            }
        }

        public boolean isContentChecksumSet() {
            return contentChecksum == 1;
        }

        public boolean isContentSizeSet() {
            return contentSize == 1;
        }

        public boolean isBlockChecksumSet() {
            return blockChecksum == 1;
        }

        public int getVersion() {
            return version;
        }

View on GitHub (pinned to c31c9215e1)

Solutions

  1. 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).
  2. 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).
  3. If reading external LZ4 data, route it through an LZ4 library that supports the produced version instead of Kafka's partial-frame implementation.
  4. Re-fetch from another replica to rule out transmission corruption.

Example fix

// before: a future/external LZ4 encoder writes version 2 frames
// (Kafka reader throws: "Version 2 is unsupported")

// after: emit version-1 LZ4 frames (Kafka's default) so FLG.VERSION matches
CompressionType compression = CompressionType.LZ4; // always writes FLG version 1
Defensive patterns

Strategy: try-catch

Validate before calling

// FLG.version is bits 6-7; only version 1 is accepted.
byte flgByte = frameBuf.get(flgOffset);
int version = (flgByte >>> 6) & 0x03;
if (version != 1) {
    throw new IOException("Refusing LZ4 frame: unsupported version " + version);
}

Type guard

null

Try / catch

try {
    try (Lz4BlockInputStream in = new Lz4BlockInputStream(payload, BufferSupplier.NO_CACHING, false)) {
        // consume
    }
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().contains("is unsupported") && e.getMessage().startsWith("Version")) {
        // Frame was produced by an LZ4 implementation using a future/incompatible frame version.
        log.warn("Unsupported LZ4 frame version on {}, skipping", tp);
        return;
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/kafka@c31c9215e1 (2026-08-03). Data as JSON: /data/errors/98dd0eb049f5a943.json. Report an issue: GitHub.