apache/cassandra · error · InvalidRequestException
Function %s requires a %s vector argument, but found argumen
Error message
Function %s requires a %s vector argument, but found argument %s of type %s
What it means
Functions accepting vector arguments validate that the argument is a ListType whose element type is assignable to the expected vector element type. validateType() throws this InvalidRequestException when the argument is not such a list (wrong container type or wrong element type). It means a vector (list) argument of the required element type was expected.
Source
Thrown at src/java/org/apache/cassandra/cql3/functions/FunctionParameter.java:392
}
@Override
public void validateType(FunctionName name, AssignmentTestable arg, AbstractType<?> argType)
{
if (argType.isVector())
{
VectorType<?> vectorType = (VectorType<?>) argType;
if (vectorType.elementType.asCQL3Type() == type)
return;
}
else if (argType instanceof ListType) // if it's terminal it will be a list
{
ListType<?> listType = (ListType<?>) argType;
if (listType.getElementsType().testAssignment(type.getType()) == NOT_ASSIGNABLE)
return;
}
throw new InvalidRequestException(format("Function %s requires a %s vector argument, " +
"but found argument %s of type %s",
name, type, arg, argType.asCQL3Type()));
}
@Override
public String toString()
{
return format("vector<%s, n>", type);
}
};
}
}
View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Pass a list literal with the correct element type, e.g. [1.0, 2.0, 3.0] for vector<float>.
- Verify the column/argument type matches the expected vector element type; recreate/ALTER if it drifted.
- Check the function's signature (FunctionFactory description) for the exact expected vector type.
- Cast via a UDF if a conversion is genuinely needed.
Example fix
// before SELECT similarity(vec, ['a','b']) FROM t; -- vector<text> passed // after SELECT similarity(vec, [1.0, 2.0]) FROM t; -- vector<float> passed
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(t instanceof ListType)) throw new IllegalArgumentException("vector arg must be a list");
ListType<?> lt = (ListType<?>) t;
if (lt.getElementsType().testAssignment(expectedElementType) == AssignmentTestable.Result.NOT_ASSIGNABLE)
throw new IllegalArgumentException("element type " + lt.getElementsType().asCQL3Type() + " not assignable"); Type guard
boolean isVectorArg(AbstractType<?> t, AbstractType<?> elem) { return t instanceof ListType && ((ListType<?>) t).getElementsType().testAssignment(elem) != AssignmentTestable.Result.NOT_ASSIGNABLE; } Try / catch
try { session.execute(q); } catch (InvalidRequestException e) { if (e.getMessage().contains("vector argument")) { /* supply list with correct element type */ } else throw e; } Prevention
- Match the vector element type (e.g. vector<float, n>) exactly
- Pass list literals with correctly typed elements
- Verify column types after schema migrations
When it happens
Trigger: Calling a vector-parameter function (e.g. vector similarity/format functions) with a non-list type, or a list whose element type does not match the expected float/vector element type (testAssignment == NOT_ASSIGNABLE).
Common situations: Passing a vector<string> where vector<float> is required; passing a single scalar instead of a list; schema drift where the column's element type changed.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Invalid vector literal for %s of type %s
- Invalid vector literal for %s: value %s is not of type %s
- Unable to create a vector selector of type %s from %d elemen
- Invalid timestamp value: <tval>
- Invalid TTL value: <tval>
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/686fa7521bc3ff38.
Report an issue: GitHub.