apache/cassandra · error · MarshalException

' is not empty

Error message

' is not empty

What it means

EmptyType is a type whose only valid value is the empty byte buffer. fromString() therefore rejects any non-empty string, throwing MarshalException quoting the offending string. It exists for columns/keys that must always be empty; anything else is invalid input.

Source

Thrown at src/java/org/apache/cassandra/db/marshal/EmptyType.java:101

    public <V> V fromComparableBytes(ValueAccessor<V> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version)
    {
        return accessor.empty();
    }

    public <VL, VR> int compareCustom(VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR)
    {
        return 0;
    }

    public <V> String getString(V value, ValueAccessor<V> accessor)
    {
        return "";
    }

    public ByteBuffer fromString(String source) throws MarshalException
    {
        if (!source.isEmpty())
            throw new MarshalException(String.format("'%s' is not empty", source));

        return ByteBufferUtil.EMPTY_BYTE_BUFFER;
    }

    @Override
    public Term fromJSONObject(Object parsed) throws MarshalException
    {
        if (!(parsed instanceof String))
            throw new MarshalException(String.format("Expected an empty string, but got: %s", parsed));
        if (!((String) parsed).isEmpty())
            throw new MarshalException(String.format("'%s' is not empty", parsed));

        return new Constants.Value(ByteBufferUtil.EMPTY_BYTE_BUFFER);
    }

    @Override
    public CQL3Type asCQL3Type()
    {

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Pass an empty string "" if the column truly is of type empty
  2. Remove or change the column type if real values need to be stored (use an appropriate type like text/int)
  3. Ensure generic serializers special-case EmptyType and write empty values

Example fix

// before
EmptyType.instance.fromString("hello"); // MarshalException
// after
EmptyType.instance.fromString("");
Defensive patterns

Strategy: type-guard

Validate before calling

if (source != null && !source.isEmpty()) throw new IllegalArgumentException("EmptyType columns must be empty");

Try / catch

try { EmptyType.instance.fromString(source); } catch (MarshalException e) { /* treat as schema/payload mismatch */ }

Prevention

When it happens

Trigger: Calling EmptyType.instance.fromString("anything") with a non-empty string, e.g. when CQL literal parsing or JSON-to-string conversion routes a real value into an empty-typed column.

Common situations: Column declared 'empty' type but application still sends values; tooling that generically calls fromString on all columns regardless of type.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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