{"record":{"id":"634300d20639adc7","repo":"apache/cassandra","slug":"constraint-s-does-not-accept-any-arguments","errorCode":null,"errorMessage":"Constraint %s does not accept any arguments.","messagePattern":"Constraint (.+?) does not accept any arguments\\.","errorType":"validation","errorClass":"InvalidConstraintDefinitionException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/constraints/ConstraintFunction.java","lineNumber":145,"sourceCode":"     *     val int check someconstraint('abc', 'def')\n     * </pre>\n     * @return true if this constraint does not accept any parameters, false otherwise.\n     */\n    public boolean isParameterless() { return true; }\n\n    @Override\n    public String toString()\n    {\n        return name;\n    }\n\n    protected void maybeThrowOnNonEmptyArguments(String constraintName)\n    {\n        if (!isParameterless())\n            return;\n\n        if (args != null && !args.isEmpty())\n            throw new InvalidConstraintDefinitionException(format(\"Constraint %s does not accept any arguments.\", constraintName));\n    }\n\n    private List<String> unquote(List<String> quotedArgs)\n    {\n        List<String> unquotedArgs = new ArrayList<>();\n        for (String quotedArg : quotedArgs)\n            unquotedArgs.add(ParseUtils.unquote(quotedArg));\n\n        return unquotedArgs;\n    }\n}\n","sourceCodeStart":127,"sourceCodeEnd":157,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/constraints/ConstraintFunction.java#L127-L157","documentation":"ConstraintFunction.maybeThrowOnNonEmptyArguments throws InvalidConstraintDefinitionException when a parameterless constraint (isParameterless() == true, e.g. the JSON constraint) is declared with arguments. Validation happens at schema definition time via validate(), so the constraint's declared argument list must be empty.","triggerScenarios":"CREATE TABLE / ALTER TABLE declaring a parameterless constraint with parentheses arguments, e.g. `col text CONSTRAINT json_value CHECK JSON('someArg')`.","commonSituations":"Copying the argument style of LENGTH-style constraints onto JSON/NOT-NULL constraints; generated DDL that always emits an argument list.","solutions":["Remove the arguments from the parameterless constraint declaration, e.g. `CHECK JSON()`.","If parameters are needed, use a constraint type that accepts arguments (e.g. LENGTH).","Adjust schema-generating code to omit arguments for parameterless constraints."],"exampleFix":"// before\npayload text CONSTRAINT CHECK JSON('strict')\n// after\npayload text CONSTRAINT CHECK JSON()","handlingStrategy":"validation","validationCode":"if (constraint.isParameterless() && args != null && !args.isEmpty())\n    throw new IllegalArgumentException(\"Constraint \" + constraint.name() + \" takes no arguments\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Emit `CHECK JSON()` with no arguments for parameterless constraints","Know which constraints are parameterless (JSON, NOT NULL) vs parameterized (LENGTH)","Validate DDL templates used by schema generators"],"tags":["cql","schema","constraints","arguments"],"backgroundTag":"missing-required-argument","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}