{"record":{"id":"1e42b3650e5dbb88","repo":"apache/cassandra","slug":"cannot-set-s-to-empty-string","errorCode":null,"errorMessage":"Cannot set %s to empty string","messagePattern":"Cannot set (.+?) to empty string","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/SchemaDescriptionStatement.java","lineNumber":59,"sourceCode":"    {\n        super(keyspaceName);\n        this.description = comment;\n        this.descriptionType = descriptionType;\n    }\n\n    @Override\n    public void validate(ClientState state)\n    {\n        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);","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/SchemaDescriptionStatement.java#L41-L77","documentation":"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').","triggerScenarios":"ALTER KEYSPACE/ALTER TABLE ... WITH comment = '' ; or CREATE ... WITH comment = ''.","commonSituations":"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 ''.","solutions":["Omit the comment option in ALTER to remove it (the statement path that ignores removal)","Set a non-empty comment string"],"exampleFix":"// before\nALTER TABLE t WITH comment = '';\n// after\nALTER TABLE t;  -- or WITH comment = 'user table metadata'","handlingStrategy":"validation","validationCode":"if (typeof comment === 'string' && comment.length === 0) {\n  delete ddl.comment; // treat empty as 'no comment'\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never emit comment = '' ; omit the option instead to clear it","Coerce empty strings to undefined before rendering DDL","Treat '' as absent in any schema-description field mapping"],"tags":["cql","schema","comment","validation"],"backgroundTag":"empty-required-field","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}