apache/cassandra · error · InvalidConstraintDefinitionException

Constraint 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.

Solutions

  1. Remove the arguments from the parameterless constraint declaration, e.g. `CHECK JSON()`.
  2. If parameters are needed, use a constraint type that accepts arguments (e.g. LENGTH).
  3. 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

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


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/634300d20639adc7. Report an issue: GitHub.

Appendix: 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)