apache/cassandra · error · IllegalArgumentException

Function does not declare an argument named '${argName}'

Error message

Function does not declare an argument named '${argName}'

What it means

Thrown by UDFContextImpl when Java UDF code calls UDFContext.newArgUDTValue()/newArgTupleValue() with an argument name that does not exist on the function's signature. Cassandra looks the name up in an internal byName map built from the CREATE FUNCTION argument list and throws IllegalArgumentException on miss.

Source

Thrown at src/java/org/apache/cassandra/cql3/functions/UDFContextImpl.java:144

    {
        if (!(dataType instanceof TupleType))
            throw new IllegalStateException("Function argument is not a tuple type but a " + dataType.getName());
        TupleType tupleType = (TupleType) dataType;
        return tupleType.newValue();
    }

    private UDFDataType getArgumentTypeByIndex(int index)
    {
        if (index < 0 || index >= argTypes.size())
            throw new IllegalArgumentException("Function does not declare an argument with index " + index);
        return argTypes.get(index);
    }

    private UDFDataType getArgumentTypeByName(String argName)
    {
        UDFDataType arg = byName.get(argName);
        if (arg == null)
            throw new IllegalArgumentException("Function does not declare an argument named '" + argName + '\'');
        return arg;
    }
}

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Check the argument names declared in the CREATE FUNCTION statement and use exactly those names in newArgUDTValue/newArgTupleValue
  2. Use the index-based accessors (e.g. via argument position) instead of name-based lookup if names are uncertain
  3. OR REPLACE the function with the corrected body or corrected argument declaration

Example fix

// before
UDTValue v = context.newArgUDTValue("adress");
// after
UDTValue v = context.newArgUDTValue("address");
Defensive patterns

Strategy: validation

Validate before calling

// Only use names exactly as declared in CREATE FUNCTION, e.g. for CREATE FUNCTION f(address frozen<address_udt>, ...)
String declaredArg = "address";
UDTValue v = context.newArgUDTValue(declaredArg);

Try / catch

try { return context.newArgUDTValue(argName); } catch (IllegalArgumentException e) { throw new IllegalStateException("UDF arg not declared: " + argName, e); }

Prevention

When it happens

Trigger: Calling newArgUDTValue("argname") or newArgTupleValue("argname") with a name not declared in the CREATE FUNCTION/OR REPLACE FUNCTION argument list; typos or case mismatches between the UDF body and declared parameter names.

Common situations: Renaming a function argument in CREATE FUNCTION without updating the UDF body; typo in the argument name string; copying UDF code from another function with different parameter names.

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/c4e0789fe589a173. Report an issue: GitHub.