apache/cassandra · error · IOException
Corrupted input: expected byte 1, 2, 3, 4 or 5; received
Error message
Corrupted input: expected byte 1, 2, 3, 4 or 5; received
What it means
deserializeSubset decodes an Unseekables that is a subset of a known superset, using the same 1-6 kind byte scheme. An unrecognized byte throws IOException, meaning the payload is not a valid serialized Unseekables subset — corruption, misalignment, or encoder/decoder version mismatch.
Source
Thrown at src/java/org/apache/cassandra/service/accord/serializers/KeySerializers.java:385
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)
{
default: throw new IOException("Corrupted input: expected byte 1, 2, 3, 4 or 5; received " + b);
case 1: kind = UnseekablesKind.RoutingKeys; result = (RS)routingKeys.deserializeSubset((AbstractUnseekableKeys) superset, in); break;
case 2: kind = UnseekablesKind.PartialKeyRoute; result = (RS)partialKeyRoute.deserializeSubset((AbstractUnseekableKeys) superset, in); break;
case 3: kind = UnseekablesKind.FullKeyRoute; result = (RS)fullKeyRoute.deserializeSubset((AbstractUnseekableKeys) superset, in); break;
case 4: kind = UnseekablesKind.RoutingRanges; result = (RS)ranges.deserializeSubset((AbstractRanges) superset, in); break;
case 5: kind = UnseekablesKind.PartialRangeRoute; result = (RS)partialRangeRoute.deserializeSubset((AbstractRanges) superset, in); break;
case 6: kind = UnseekablesKind.FullRangeRoute; result = (RS)fullRangeRoute.deserializeSubset((AbstractRanges) superset, in); break;
}
Invariants.require(permitted.contains(kind));
return result;
}
public void skip(DataInputPlus in) throws IOException
{
countAndSkip(in);
}
public void skip(UnseekablesKind kind, DataInputPlus in) throws IOException
{View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Ensure all nodes use compatible Accord serializer versions (complete rolling upgrade).
- Inspect the received byte against UnseekablesKind values to find the encoding mismatch.
- Check the connection for earlier deserialization errors that misaligned the stream and reset it if found.
- Update the switch when new UnseekablesKind values are introduced.
Defensive patterns
Strategy: try-catch
Try / catch
try {
Unseekables<?, ?> subset = serializer.deserializeSubset(superset, in);
} catch (IOException e) {
if (e.getMessage().startsWith("Corrupted input")) {
logger.warn("Corrupt Unseekables subset payload; dropping message", e);
} else throw e;
} Prevention
- Keep serializer versions aligned across the cluster.
- Validate subset/superset pairing in tests (same kind family).
- Reset connections after any parse failure to avoid cascading misreads.
When it happens
Trigger: deserializeSubset(superset, in) reads a kind byte outside 1..6 when decoding a subset of Unseekables/Route relative to a superset.
Common situations: Rolling-upgrade version skew; corrupted or truncated network data; a preceding read failure leaving the stream mid-record; tests passing fabricated bytes.
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
- Corrupted input: expected byte 1, 2, 3, 4, 5 or 6; received
- Unhandled CheckStatusReply kind:
- Corrupted input: expected byte 1 or 2, received " + b
- Invalid 64-bits double value, expecting 8 bytes but got
- Invalid 32-bits float value, expecting 4 bytes but got
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/bec2f9549a66157e.
Report an issue: GitHub.