apache/cassandra · error · MarshalException
Invalid bytes remaining after an end-of-component at compone
Error message
Invalid bytes remaining after an end-of-component at component
What it means
Thrown by AbstractCompositeType when deserializing/validating a composite value: after reading a component's end-of-component byte (0), additional bytes were found before the next component starts. The serialized composite is malformed — components must be terminated by exactly one zero byte with no trailing garbage in that slice.
Source
Thrown at src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java:328
offset += getComparatorSize(i, input, accessor, offset);
if (accessor.sizeFromOffset(input, offset) < 2)
throw new MarshalException("Not enough bytes to read value size of component " + i);
int length = accessor.getUnsignedShort(input, offset);
offset += 2;
if (accessor.sizeFromOffset(input, offset) < length)
throw new MarshalException("Not enough bytes to read value of component " + i);
V value = accessor.slice(input, offset, length);
offset += length;
comparator.validateCollectionMember(value, previous, accessor);
if (accessor.isEmptyFromOffset(input, offset))
throw new MarshalException("Not enough bytes to read the end-of-component byte of component" + i);
byte b = accessor.getByte(input, offset++);
if (b != 0 && !accessor.isEmptyFromOffset(input, offset))
throw new MarshalException("Invalid bytes remaining after an end-of-component at component" + i);
previous = value;
++i;
}
}
@Override
public void checkConstraints(ByteBuffer input, ColumnConstraints constraints) throws ConstraintViolationException
{
// no constraints defined for the partition keys
if (!constraints.hasRelevantConstraints())
return;
ValueAccessor<ByteBuffer> accessor = ByteBufferAccessor.instance;
boolean isStatic = readIsStatic(input, accessor);
int offset = startingOffset(isStatic);
View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Regenerate the composite value using CompositeType.build() / the official serializer instead of hand-assembling bytes.
- Check for data corruption: run scrub/verify on affected SSTables and restore from backup if needed.
- Verify the client driver or tool writes composite values with correct length-prefixed components and a single terminating 0 byte.
Example fix
// before: hand-built composite
ByteBuffer bad = ByteBuffer.allocate(bytes.length + 1);
bad.put(bytes).put((byte) 0);
// after
ByteBuffer good = CompositeType.getInstance(BytesType.instance)
.decompose("cell-name"); Defensive patterns
Strategy: validation
Validate before calling
ByteBuffer v = serialized;
// round-trip check before use
try { compositeType.validate(v); } catch (MarshalException e) { /* rebuild with CompositeType.build() */ } Type guard
boolean isValidComposite(ByteBuffer v) { try { compositeType.validate(v.duplicate()); return true; } catch (MarshalException e) { return false; } } Try / catch
catch (MarshalException e) { log.error("corrupt composite value", e); value = rebuildComposite(rawBytes); } Prevention
- Always build composites via CompositeType.build()/decompose, never raw byte assembly.
- Validate any externally produced byte buffers before storing.
- Run periodic scrub/verify to catch on-disk corruption early.
When it happens
Trigger: Calling AbstractCompositeType (or a subclass like CompositeType) validate/compose on a ByteBuffer whose serialized bytes contain non-zero bytes immediately after an end-of-component marker (byte != 0 at offset after marker while bytes remain).
Common situations: Corrupted SSTable or mutation data; hand-built composite ByteBuffers with wrong offsets/lengths; bugs in tools or drivers writing composite values directly; partial reads truncating a value incorrectly.
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
- Not enough bytes to read value size of component
- Not enough bytes to read value of component
- Not enough bytes to read the end-of-component byte of compon
- Not enough bytes to header of the comparator part of compone
- Not enough bytes to read comparator name of component %s
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/fb2b9506a9442fe5.
Report an issue: GitHub.