apache/cassandra · error · InvalidRequestException

Cannot set %s to empty string

Error message

Cannot set %s to empty string

What it means

Schema description comments (e.g. WITH comment = ... on keyspaces/tables) may not be the empty string; an empty description is treated as invalid rather than as 'remove the comment'. SchemaDescriptionStatement.validate() throws InvalidRequestException with the description type name (e.g. 'Comment').

Source

Thrown at src/java/org/apache/cassandra/cql3/statements/schema/SchemaDescriptionStatement.java:59

    {
        super(keyspaceName);
        this.description = comment;
        this.descriptionType = descriptionType;
    }

    @Override
    public void validate(ClientState state)
    {
        super.validate(state);
        if(description == null)
        {
            // Statement is removing comment on schema elements, ignore
            return;
        }

        if(description.isEmpty())
        {
            throw new InvalidRequestException(String.format("Cannot set %s to empty string", descriptionType.value));
        }

        if (description.length() > descriptionType.maxLength)
        {
            String msg = String.format("%s length (%d) exceeds maximum allowed length (%d)",
                                       descriptionType.value,
                                       description.length(),
                                       descriptionType.maxLength);
            throw new InvalidRequestException(msg);
        }
    }

    protected KeyspaceMetadata validateAndGetKeyspace(Keyspaces schema)
    {
        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);

        if (null == keyspace)
            throw ire("Keyspace '%s' doesn't exist", keyspaceName);

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Omit the comment option in ALTER to remove it (the statement path that ignores removal)
  2. Set a non-empty comment string

Example fix

// before
ALTER TABLE t WITH comment = '';
// after
ALTER TABLE t;  -- or WITH comment = 'user table metadata'
Defensive patterns

Strategy: validation

Validate before calling

if (typeof comment === 'string' && comment.length === 0) {
  delete ddl.comment; // treat empty as 'no comment'
}

Prevention

When it happens

Trigger: ALTER KEYSPACE/ALTER TABLE ... WITH comment = '' ; or CREATE ... WITH comment = ''.

Common situations: Trying to clear a comment by setting it to empty string (correct way: omit the comment option entirely or set it to null/absent so the statement removes it); automated schema generation producing ''.

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/1e42b3650e5dbb88. Report an issue: GitHub.