apache/cassandra · error · InvalidRequestException

length ( ) exceeds maximum allowed length ( )

Error message

%s length (%d) exceeds maximum allowed length (%d)

What it means

Each schema description field (comment, keyspace/table descriptions) has a maximum allowed length (descriptionType.maxLength). If the supplied description exceeds it, validate() throws InvalidRequestException reporting the actual and maximum lengths.

Solutions

  1. Shorten the description text below the max length
  2. Move long documentation outside the schema (e.g. external docs) and keep a brief comment

Example fix

// before
ALTER TABLE t WITH comment = '<2000-char doc>';
// after
ALTER TABLE t WITH comment = 'short summary of table purpose';
Defensive patterns

Strategy: validation

Validate before calling

const MAX_COMMENT = 1024; // per descriptionType.maxLength
if (comment && comment.length > MAX_COMMENT) {
  throw new Error(`description length ${comment.length} exceeds max ${MAX_COMMENT}`);
}

Prevention

When it happens

Trigger: CREATE/ALTER keyspace or table with a comment/description whose string length exceeds the declared maxLength for that description type.

Common situations: Pasting long documentation, generated JSON, or auto-generated docs into the comment option; ORM layers serializing object descriptions verbatim.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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

Appendix: source

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

        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);

        return keyspace;
    }

    protected TableMetadata validateAndGetTable(Keyspaces schema, String tableName)
    {
        KeyspaceMetadata keyspaceMetadata = validateAndGetKeyspace(schema);

        TableMetadata tableMetadata = keyspaceMetadata.getTableOrViewNullable(tableName);

View on GitHub (pinned to 88fd0f6a0e)