{"record":{"id":"953e2979ca0651e3","repo":"apache/cassandra","slug":"s-length-d-exceeds-maximum-allowed-length-d","errorCode":null,"errorMessage":"%s length (%d) exceeds maximum allowed length (%d)","messagePattern":"(.+?) length \\((.+?)\\) exceeds maximum allowed length \\((.+?)\\)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/SchemaDescriptionStatement.java","lineNumber":68,"sourceCode":"        super.validate(state);\n        if(description == null)\n        {\n            // Statement is removing comment on schema elements, ignore\n            return;\n        }\n\n        if(description.isEmpty())\n        {\n            throw new InvalidRequestException(String.format(\"Cannot set %s to empty string\", descriptionType.value));\n        }\n\n        if (description.length() > descriptionType.maxLength)\n        {\n            String msg = String.format(\"%s length (%d) exceeds maximum allowed length (%d)\",\n                                       descriptionType.value,\n                                       description.length(),\n                                       descriptionType.maxLength);\n            throw new InvalidRequestException(msg);\n        }\n    }\n\n    protected KeyspaceMetadata validateAndGetKeyspace(Keyspaces schema)\n    {\n        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);\n\n        if (null == keyspace)\n            throw ire(\"Keyspace '%s' doesn't exist\", keyspaceName);\n\n        return keyspace;\n    }\n\n    protected TableMetadata validateAndGetTable(Keyspaces schema, String tableName)\n    {\n        KeyspaceMetadata keyspaceMetadata = validateAndGetKeyspace(schema);\n\n        TableMetadata tableMetadata = keyspaceMetadata.getTableOrViewNullable(tableName);","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/SchemaDescriptionStatement.java#L50-L86","documentation":"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.","triggerScenarios":"CREATE/ALTER keyspace or table with a comment/description whose string length exceeds the declared maxLength for that description type.","commonSituations":"Pasting long documentation, generated JSON, or auto-generated docs into the comment option; ORM layers serializing object descriptions verbatim.","solutions":["Shorten the description text below the max length","Move long documentation outside the schema (e.g. external docs) and keep a brief comment"],"exampleFix":"// before\nALTER TABLE t WITH comment = '<2000-char doc>';\n// after\nALTER TABLE t WITH comment = 'short summary of table purpose';","handlingStrategy":"validation","validationCode":"const MAX_COMMENT = 1024; // per descriptionType.maxLength\nif (comment && comment.length > MAX_COMMENT) {\n  throw new Error(`description length ${comment.length} exceeds max ${MAX_COMMENT}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check string length against the schema limit before building DDL","Truncate or summarize long documentation before storing it as a comment","Keep schema comments brief; store long docs externally"],"tags":["cql","schema","length-limit"],"backgroundTag":"value-out-of-range","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}