apache/cassandra · error · InvalidTypeException
Not enough bytes to deserialize a map
Error message
Not enough bytes to deserialize a map
What it means
BufferUnderflowException-style InvalidTypeException from the map codec's deserialize: the input buffer does not contain enough bytes for the declared number of key/value pairs (size read via CodecUtils.readSize, then each entry via readValue). Truncated or corrupt serialized map data triggers it.
Solutions
- Verify the bytes were produced by the same codec/protocol version on both ends
- Check for truncation of the blob (column type mismatch, manual byte manipulation)
- Re-write the data from the original source instead of patching the corrupted buffer
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java:2516 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/4ee6556f8219c0ff.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java:2516
if (bytes == null || bytes.remaining() == 0) return newInstance(0);
try
{
ByteBuffer input = bytes.duplicate();
int n = CodecUtils.readSize(input, protocolVersion);
Map<K, V> m = newInstance(n);
for (int i = 0; i < n; i++)
{
ByteBuffer kbb = CodecUtils.readValue(input, protocolVersion);
ByteBuffer vbb = CodecUtils.readValue(input, protocolVersion);
m.put(
keyCodec.deserialize(kbb, protocolVersion),
valueCodec.deserialize(vbb, protocolVersion));
}
return m;
}
catch (BufferUnderflowException e)
{
throw new InvalidTypeException("Not enough bytes to deserialize a map", e);
}
}
/**
* Return a new {@link Map} instance with the given estimated size.
*
* @param size The estimated size of the collection to create.
* @return A new {@link Map} instance with the given estimated size.
*/
protected abstract Map<K, V> newInstance(int size);
}
/**
* This codec maps a CQL {@link DataType#map(DataType, DataType) map type} to a Java {@link Map}.
* Implementation note: this codec returns mutable, non thread-safe {@link LinkedHashMap}
* instances.
*/
private static class MapCodec<K, V> extends AbstractMapCodec<K, V>View on GitHub (pinned to 88fd0f6a0e)