{"record":{"id":"8e56b97b25abe362","repo":"apache/cassandra","slug":"s-is-not-a-valid-function-resource-name-it-must","errorCode":null,"errorMessage":"%s is not a valid function resource name. It must end with \"[]\"","messagePattern":"(.+?) is not a valid function resource name\\. It must end with \"\\[\\]\"","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/auth/FunctionResource.java","lineNumber":201,"sourceCode":"     * @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);\n\n        return function(parts[1], functionName, functionArgs.isEmpty() ? Collections.emptyList() : argsListFromString(functionArgs));\n    }\n\n    /**\n     * @return Printable name of the resource.\n     */\n    public String getName()\n    {","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/auth/FunctionResource.java#L183-L219","documentation":"When FunctionResource.fromName sees a 3-part name, the last part must be the function name followed by a bracketed argument list. It throws IllegalArgumentException if the full name does not match the regex ^.+\\[.*\\]$, i.e. there is no trailing '[...]' argument block.","triggerScenarios":"Parsing a name like 'functions/ks/fn' (missing '[]'), 'functions/ks/fn(' (unclosed bracket), or 'functions/ks/[int]' where the regex-match fails on the whole name rather than the third part.","commonSituations":"Building function resource names by hand and forgetting the argument list; overloads recorded without '[]'; truncation of stored permission strings; generating names from signatures without argument types.","solutions":["Append an argument list: 'functions/<ks>/<fn>[<type>,<type>]' — use '[]' for zero-arg overloads","Construct via FunctionResource.function(keyspace, name, argTypes) so formatting is handled for you","Inspect the stored name for truncation or missing brackets before parsing"],"exampleFix":"// before\nFunctionResource r = FunctionResource.fromName(\"functions/ks/fn\");\n// after\nFunctionResource r = FunctionResource.fromName(\"functions/ks/fn[int]\");","handlingStrategy":"validation","validationCode":"boolean hasArgsBlock(String name) {\n    return name.matches(\"^.+\\\\[.*\\\\]$\");\n}","typeGuard":null,"tryCatchPattern":"try { FunctionResource r = FunctionResource.fromName(name); } catch (IllegalArgumentException e) { log.error(\"function resource missing [args] block: {}\", name); }","preventionTips":["Always append the bracketed argument list, using '[]' for zero-arg overloads","Prefer FunctionResource.function(ks, name, argTypes) over string concatenation","Check stored names for truncation before re-parsing"],"tags":["cassandra","auth","resource-name","format"],"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"}