apache/cassandra · error · IllegalArgumentException
%s is not a valid function resource name
Error message
%s is not a valid function resource name
What it means
FunctionResource.fromName parses a stored function resource name such as 'functions', 'functions/<ks>' or 'functions/<ks>/<name>[args]'. It throws IllegalArgumentException when the first segment is not the literal root 'functions', meaning the string is not a valid function resource name.
Source
Thrown at src/java/org/apache/cassandra/auth/FunctionResource.java:192
* Parses a resource name into a FunctionResource instance.
* A valid resource name for function should be in the follow format:
* functions/KEYSPACE/FUNCTION_NAME[FUNCTION_ARGS]
* Note that
* 1. FUNCTION_NAME could contain any character due to the use of quoted text in CQL.
* 2. FUNCTION_ARGS could be empty. If it is not empty, it is expressed in this format:
* FUNCTION_ARG1^FUNCTION_ARG2... where ^ is the delimiter for arguments
*
* @param name Name of the function resource.
* @return FunctionResource instance matching the name.
*/
public static FunctionResource fromName(String name)
{
// Split the name into at most 3 parts.
// The last part is the function name + args list, the name might contains '/'
String[] parts = StringUtils.split(name, "/", 3);
if (!parts[0].equals(ROOT_NAME))
throw new IllegalArgumentException(String.format("%s is not a valid function resource name", name));
if (parts.length == 1)
return root();
if (parts.length == 2)
return keyspace(parts[1]);
if (!name.matches("^.+\\[.*\\]$"))
throw new IllegalArgumentException(String.format("%s is not a valid function resource name. It must end with \"[]\"", name));
String function = parts[2];
// The name must end with '[...]' block
int lastStartingBracketIndex = function.lastIndexOf('[');
String functionName = StringUtils.substring(function, 0, lastStartingBracketIndex);
String functionArgs = StringUtils.substring(function,
// excludes the wrapping brackets [ ]
lastStartingBracketIndex + 1,
function.length() - 1);View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Ensure the name begins with the exact root 'functions' followed by at most two more slash-separated segments
- Use the typed factories FunctionResource.root()/keyspace()/function() instead of string parsing
- Check that the resource kind matches: data resources must be parsed with DataResource.fromName, JMX with JMXResource.fromName
Example fix
// before
FunctionResource r = FunctionResource.fromName("data/ks/fn[int]");
// after
FunctionResource r = FunctionResource.fromName("functions/ks/fn[int]"); Defensive patterns
Strategy: validation
Validate before calling
boolean isValidFunctionResourceName(String name) {
String[] parts = name.split("/", 3);
return parts.length >= 1 && "functions".equals(parts[0]);
} Try / catch
try { FunctionResource r = FunctionResource.fromName(name); } catch (IllegalArgumentException e) { log.error("not a function resource: {}", name); } Prevention
- Persist resources with FunctionResource.toString()/getName() output, never hand-built strings
- Route each resource kind to its own fromName implementation
- Watch for typos in the 'functions' root prefix
When it happens
Trigger: Calling FunctionResource.fromName with a name whose first slash-segment is not 'functions' (e.g. 'data/ks/tbl', 'jmx/...', 'funtions/ks' typo), or with an empty string so parts[0] doesn't match.
Common situations: Mixing up resource-kind prefixes when deserializing permissions; corrupted or hand-edited entries in a permissions store; scripted grant statements that concatenate the wrong prefix.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- %s is not a valid data resource name
- %s is not a valid function resource name. It must end with "
- %s is not a valid JMX resource name
- REVOKE operation is not supported by AllowAllAuthorizer
- In this context function name must be explictly qualified by
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/971f96db341d2b11.
Report an issue: GitHub.