apache/cassandra · error · MarshalException

EmptyType only accept empty values

Error message

EmptyType only accept empty values

What it means

EmptyType is a special Cassandra comparator that can only store zero-length byte values. The serializer's validate() rejects any non-empty byte buffer, because EmptyType has no meaningful representation for actual data. It is typically used as a dummy key type where the value carries no information.

Solutions

  1. Write only empty values (0 bytes) to columns typed EmptyType; use an explicit empty marker per your CQL version (e.g. 0x blob literal) or leave the column unset.
  2. Check the table schema (DESCRIBE / system_schema) and change the column to the intended type (int, text, blob) if EmptyType was chosen by mistake.
  3. If used as a dummy partition-key component to keep rows in one partition, ensure the application serializes nothing for that component.

Example fix

// before
session.execute("INSERT INTO t (pk, empty_col) VALUES (1, 42)");
// after
session.execute("INSERT INTO t (pk, empty_col) VALUES (1, 0x)"); // or omit empty_col entirely
Defensive patterns

Strategy: validation

Validate before calling

if (value != null && value.remaining() > 0) throw new IllegalArgumentException("EmptyType columns accept only 0-byte values");

Type guard

boolean isEmptyTypeValue(java.nio.ByteBuffer b) { return b == null || b.remaining() == 0; }

Prevention

When it happens

Trigger: Calling EmptyType.validate(value, accessor) (directly or via deserialize/validation paths such as compare or asCQLType) with a byte buffer whose size is greater than 0.

Common situations: Declaring a column or clustering key as EmptyType and then INSERTing a non-null literal (e.g. int or text) instead of leaving it empty/null; a driver or migration writing real bytes into an EmptyType column; accidental use of EmptyType instead of the intended type in a table schema.

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/3e1811dc17e2c012. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/serializers/EmptySerializer.java:44

public class EmptySerializer extends TypeSerializer<Void>
{
    public static final EmptySerializer instance = new EmptySerializer();

    public <V> Void deserialize(V value, ValueAccessor<V> accessor)
    {
        validate(value, accessor);
        return null;
    }

    public ByteBuffer serialize(Void value)
    {
        return ByteBufferUtil.EMPTY_BYTE_BUFFER;
    }

    public <V> void validate(V value, ValueAccessor<V> accessor) throws MarshalException
    {
        if (!accessor.isEmpty(value))
            throw new MarshalException("EmptyType only accept empty values");
    }

    public String toString(Void value)
    {
        return "";
    }

    public Class<Void> getType()
    {
        return Void.class;
    }
}

View on GitHub (pinned to 88fd0f6a0e)