apache/cassandra · error · InvalidConstraintDefinitionException
Constraint %s does not accept any arguments.
Error message
Constraint %s does not accept any arguments.
What it means
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.
Source
Thrown at src/java/org/apache/cassandra/cql3/constraints/ConstraintFunction.java:145
* val int check someconstraint('abc', 'def')
* </pre>
* @return true if this constraint does not accept any parameters, false otherwise.
*/
public boolean isParameterless() { return true; }
@Override
public String toString()
{
return name;
}
protected void maybeThrowOnNonEmptyArguments(String constraintName)
{
if (!isParameterless())
return;
if (args != null && !args.isEmpty())
throw new InvalidConstraintDefinitionException(format("Constraint %s does not accept any arguments.", constraintName));
}
private List<String> unquote(List<String> quotedArgs)
{
List<String> unquotedArgs = new ArrayList<>();
for (String quotedArg : quotedArgs)
unquotedArgs.add(ParseUtils.unquote(quotedArg));
return unquotedArgs;
}
}
View on GitHub (pinned to 88fd0f6a0e)
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.
Example fix
// before
payload text CONSTRAINT CHECK JSON('strict')
// after
payload text CONSTRAINT CHECK JSON() Defensive patterns
Strategy: validation
Validate before calling
if (constraint.isParameterless() && args != null && !args.isEmpty())
throw new IllegalArgumentException("Constraint " + constraint.name() + " takes no arguments"); Prevention
- 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
When it happens
Trigger: CREATE TABLE / ALTER TABLE declaring a parameterless constraint with parentheses arguments, e.g. `col text CONSTRAINT json_value CHECK JSON('someArg')`.
Common situations: Copying the argument style of LENGTH-style constraints onto JSON/NOT-NULL constraints; generated DDL that always emits an argument list.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Constraint '%s' can be used only for columns of type %s but
- Constraint cannot be defined on the column <name> of type <t
- There are duplicate constraint definitions on column '%s': %
- Constraint %s was not specified on a column it operates on:
- %s constraint can not be specified on a %s key column '%s'
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/634300d20639adc7.
Report an issue: GitHub.