{"record":{"id":"971f96db341d2b11","repo":"apache/cassandra","slug":"s-is-not-a-valid-function-resource-name","errorCode":null,"errorMessage":"%s is not a valid function resource name","messagePattern":"(.+?) is not a valid function resource name","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/auth/FunctionResource.java","lineNumber":192,"sourceCode":"     * Parses a resource name into a FunctionResource instance.\n     * A valid resource name for function should be in the follow format:\n     * functions/KEYSPACE/FUNCTION_NAME[FUNCTION_ARGS]\n     * Note that\n     * 1. FUNCTION_NAME could contain any character due to the use of quoted text in CQL.\n     * 2. FUNCTION_ARGS could be empty. If it is not empty, it is expressed in this format:\n     *    FUNCTION_ARG1^FUNCTION_ARG2... where ^ is the delimiter for arguments\n     *\n     * @param name Name of the function resource.\n     * @return FunctionResource instance matching the name.\n     */\n    public static FunctionResource fromName(String name)\n    {\n        // Split the name into at most 3 parts.\n        // The last part is the function name + args list, the name might contains '/'\n        String[] parts = StringUtils.split(name, \"/\", 3);\n\n        if (!parts[0].equals(ROOT_NAME))\n            throw new IllegalArgumentException(String.format(\"%s is not a valid function resource name\", name));\n\n        if (parts.length == 1)\n            return root();\n\n        if (parts.length == 2)\n            return keyspace(parts[1]);\n\n        if (!name.matches(\"^.+\\\\[.*\\\\]$\"))\n            throw new IllegalArgumentException(String.format(\"%s is not a valid function resource name. It must end with \\\"[]\\\"\", name));\n\n        String function = parts[2];\n        // The name must end with '[...]' block\n        int lastStartingBracketIndex = function.lastIndexOf('[');\n        String functionName = StringUtils.substring(function, 0, lastStartingBracketIndex);\n        String functionArgs = StringUtils.substring(function,\n                                                    // excludes the wrapping brackets [ ]\n                                                    lastStartingBracketIndex + 1,\n                                                    function.length() - 1);","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/auth/FunctionResource.java#L174-L210","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nFunctionResource r = FunctionResource.fromName(\"data/ks/fn[int]\");\n// after\nFunctionResource r = FunctionResource.fromName(\"functions/ks/fn[int]\");","handlingStrategy":"validation","validationCode":"boolean isValidFunctionResourceName(String name) {\n    String[] parts = name.split(\"/\", 3);\n    return parts.length >= 1 && \"functions\".equals(parts[0]);\n}","typeGuard":null,"tryCatchPattern":"try { FunctionResource r = FunctionResource.fromName(name); } catch (IllegalArgumentException e) { log.error(\"not a function resource: {}\", name); }","preventionTips":["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"],"tags":["cassandra","auth","resource-name","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}