apache/cassandra · error · IOException

Corrupted input: expected byte 1, 2, 3, 4, 5 or 6; received

Error message

Corrupted input: expected byte 1, 2, 3, 4, 5 or 6; received 

What it means

The Unseekables serializer reads a kind byte and dispatches to one of six sub-serializers (RoutingKeys through FullRangeRoute, bytes 1-6). Any other byte throws IOException because the stream does not represent a valid serialized Unseekables. Causes are corruption, truncation/misalignment, or a peer encoding kinds this version does not know.

Solutions

  1. Confirm cluster nodes run compatible versions so the UnseekablesKind encoding matches (finish rolling upgrade).
  2. Log the received byte and cross-check against UnseekablesKind values to identify the mismatched encoder.
  3. Look for earlier exceptions on the same connection that may have desynchronized the stream; reset the session.
  4. If a new kind was added, update this serializer's switch and the documented byte range in the message.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    Unseekables<?, ?> u = UnseekablesSerializer.deserialize(in, version);
} catch (IOException e) {
    if (e.getMessage().startsWith("Corrupted input")) {
        logger.warn("Corrupt Unseekables payload; discarding and resetting stream", e);
        // drop message / close connection to resynchronize
    } else throw e;
}

Prevention

When it happens

Trigger: deserialize(DataInputPlus) reads a byte not in 1..6 while decoding an Unseekables/Route object, e.g. during Accord command/message deserialization.

Common situations: Version skew during rolling upgrades; corrupted network payload; stream misaligned by a prior deserialization bug; synthetic test data with a bad tag.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/b641d77e898f401f. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/service/accord/serializers/KeySerializers.java:366

                    out.writeByte(5);
                    partialRangeRoute.serializeSubset((PartialRangeRoute)t, superset, out);
                    break;
                case FullRangeRoute:
                    out.writeByte(6);
                    fullRangeRoute.serializeSubset((FullRangeRoute)t, superset, out);
                    break;
            }
        }

        @Override
        public RS deserialize(DataInputPlus in) throws IOException
        {
            byte b = in.readByte();
            UnseekablesKind kind;
            RS result;
            switch (b)
            {
                default: throw new IOException("Corrupted input: expected byte 1, 2, 3, 4, 5 or 6; received " + b);
                case 1: kind = UnseekablesKind.RoutingKeys; result = (RS)routingKeys.deserialize(in); break;
                case 2: kind = UnseekablesKind.PartialKeyRoute; result = (RS)partialKeyRoute.deserialize(in); break;
                case 3: kind = UnseekablesKind.FullKeyRoute; result = (RS)fullKeyRoute.deserialize(in); break;
                case 4: kind = UnseekablesKind.RoutingRanges; result = (RS)ranges.deserialize(in); break;
                case 5: kind = UnseekablesKind.PartialRangeRoute; result = (RS)partialRangeRoute.deserialize(in); break;
                case 6: kind = UnseekablesKind.FullRangeRoute; result = (RS)fullRangeRoute.deserialize(in); break;
            }
            Invariants.require(permitted.contains(kind));
            return result;
        }

        public RS deserializeSubset(Unseekables<?> superset, DataInputPlus in) throws IOException
        {
            byte b = in.readByte();
            UnseekablesKind kind;
            RS result;
            switch (b)
            {

View on GitHub (pinned to 88fd0f6a0e)