{"record":{"id":"fe0065115f0a0cf7","repo":"apache/cassandra","slug":"message-of-wrapped-invalidconstraintdefinitionexc","errorCode":null,"errorMessage":"(message of wrapped InvalidConstraintDefinitionException)","messagePattern":"\\(message of wrapped InvalidConstraintDefinitionException\\)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/schema/TableMetadata.java","lineNumber":653,"sourceCode":"                    except(\"Cannot have a counter column (\\\"%s\\\") in a non counter table\", column.name);\n        }\n\n        // All tables should have a partition key\n        if (partitionKeyColumns.isEmpty())\n            except(\"Missing partition keys for table %s\", toString());\n\n        indexes.validate(this);\n\n        for (ColumnMetadata columnMetadata : columns())\n        {\n            ColumnConstraints constraints = columnMetadata.getColumnConstraints();\n            try\n            {\n                constraints.validate(columnMetadata);\n            }\n            catch (InvalidConstraintDefinitionException e)\n            {\n                throw new InvalidRequestException(e.getMessage(), e);\n            }\n        }\n\n        require((params.transactionalMode == TransactionalMode.off && params.transactionalMigrationFrom == TransactionalMigrationFromMode.none) || !isCounter(), \"Counters are not supported with Accord for table \" + this);\n    }\n\n    private void validateTableName()\n    {\n        if (!isValidCharsName(name))\n            except(\"Table name must not be empty or not contain non-alphanumeric-underscore characters (got \\\"%s\\\")\", name);\n\n        if (name.length() > TABLE_NAME_LENGTH)\n            except(\"Table name must not be more than %d characters long (got %d characters for \\\"%s\\\")\", TABLE_NAME_LENGTH, name.length(), name);\n\n        assert getTableDirectoryName().length() <= FILENAME_LENGTH : String.format(\"Generated directory name for a table of %d characters doesn't fit the max filename legnth of %s. This unexpectedly wasn't prevented by check of the table name length, %d, to fit %d characters (got table name \\\"%s\\\" and generated directory name \\\"%s\\\"\", getTableDirectoryName().length(), FILENAME_LENGTH, name.length(), TABLE_NAME_LENGTH, name, getTableDirectoryName());\n    }\n\n    /**","sourceCodeStart":635,"sourceCodeEnd":671,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/schema/TableMetadata.java#L635-L671","documentation":"During TableMetadata.validate, column constraint validation failures (InvalidConstraintDefinitionException) are re-wrapped as InvalidRequestException preserving the original message. The table's constraint definitions are semantically invalid and cannot be announced.","triggerScenarios":"Creating or altering a table (apply/announceNewTable/announceTableUpdate) whose column metadata fails SchemaConstraints/constraints.validate(columnMetadata) — e.g. an invalid column constraint definition in CREATE TABLE / ALTER TABLE.","commonSituations":"Hand-written DDL with malformed constraint options; migration tools generating unsupported constraint combinations; version upgrades where a previously tolerated constraint definition is now rejected.","solutions":["Read the wrapped message — it names the specific invalid constraint definition","Fix or remove the offending column constraint in the CREATE/ALTER statement","Validate the DDL against the Cassandra version's supported constraint syntax","If coming from an upgrade path, update legacy schema definitions before announcing"],"exampleFix":"// before\nCREATE TABLE t (k int PRIMARY KEY, v int WITH invalid_constraint_option);\n// after\nCREATE TABLE t (k int PRIMARY KEY, v int);","handlingStrategy":"validation","validationCode":"// Validate constraints in a staging keyspace first: apply the DDL to a test table and catch InvalidRequestException before production announce.","typeGuard":null,"tryCatchPattern":"try { schemaChange(ddl); } catch (InvalidRequestException e) { throw new SchemaValidationException(\"Invalid column constraint: \" + e.getMessage(), e); }","preventionTips":["Validate DDL against the target Cassandra version before rollout","Test schema migrations on a staging cluster first","Avoid hand-writing constraint definitions; generate them from supported tooling","Keep migration tools and server versions aligned"],"tags":["cassandra","schema","validation"],"backgroundTag":"schema-validation-failed","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"}