apache/cassandra · error · MarshalException

Not enough bytes to read a + name

Error message

Not enough bytes to read a + name

What it means

AbstractMapSerializer.getSliceFromSerialized converts the catch-all BufferUnderflowException/IndexOutOfBoundsException raised while walking a serialized map/set into MarshalException("Not enough bytes to read a map"). It means the supplied serialized collection buffer is truncated or corrupt relative to its declared element count.

Solutions

  1. Verify the value was written with the correct collection type; a map read as a set (or vice versa) yields truncated parsing.
  2. Re-read/repair the affected data (nodetool scrub/repair) if the stored value is corrupt on disk.
  3. In client code, ensure the serialized buffer is complete before calling collection slicing APIs.
  4. Catch MarshalException around deserialization and treat the value as unreadable, logging the hex of the input.

Example fix

// before
List<ByteBuffer> slices = type.getSliceFromSerialized(value, start, end); // MarshalException
// after
try {
    slices = type.getSliceFromSerialized(value, start, end);
} catch (MarshalException e) {
    logger.warn("Corrupt collection value: {}", ByteBufferUtil.bytesToHex(value));
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (value == null || value.remaining() < 4) throw new MarshalException("collection buffer too short");

Try / catch

try { slices = mapType.getSliceFromSerialized(value, from, to); } catch (MarshalException e) { logger.warn("Truncated map cell: {}", ByteBufferUtil.bytesToHex(value), e); }

Prevention

When it happens

Trigger: Calling getSliceFromSerialized (used for frozen collection slicing in CQL) with a ByteBuffer shorter than the header/element count claims — e.g. a corrupted stored value, wrong comparator usage, or hand-built byte buffers missing elements (src/java/org/apache/cassandra/serializers/AbstractMapSerializer.java:112).

Common situations: Corrupted SSTable or hinted data; client drivers writing malformed frozen map values; custom tooling reading cells with truncated buffers; deserializing a value with the wrong type.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/serializers/AbstractMapSerializer.java:112

                }

                // Otherwise, we'll include that element
                skipMapValue(input); // value
                ++count;

                // But if we know it was the last of the slice, we break early
                if (comparison == 0)
                    break;
            }

            if (count == 0 && !frozen)
                return null;

            return copyAsNewCollection(collection, count, startPos, input.position());
        }
        catch (BufferUnderflowException | IndexOutOfBoundsException e)
        {
            throw new MarshalException("Not enough bytes to read a " + name);
        }
    }

    @Override
    public int getIndexFromSerialized(ByteBuffer collection, ByteBuffer key, AbstractType<?> comparator)
    {
        try
        {
            ByteBuffer input = collection.duplicate();
            int n = readCollectionSize(input, ByteBufferAccessor.instance);
            int offset = sizeOfCollectionSize();
            for (int i = 0; i < n; i++)
            {
                ByteBuffer kbb = readValue(input, ByteBufferAccessor.instance, offset);
                offset += sizeOfValue(kbb, ByteBufferAccessor.instance);
                int comparison = comparator.compareForCQL(kbb, key);

                if (comparison == 0)

View on GitHub (pinned to 88fd0f6a0e)