{"record":{"id":"eb331623afb53e26","repo":"apache/cassandra","slug":"an-error-was-encountered-when-looking-up-function","errorCode":null,"errorMessage":"An error was encountered when looking up function definition: ","messagePattern":"An error was encountered when looking up function definition: ","errorType":"console","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/InvalidatePermissionsCache.java","lineNumber":181,"sourceCode":"\n            if (StringUtils.isNotEmpty(mBean))\n                resourceNames.add(JMXResource.mbean(mBean).getName());\n\n            if (resourceNames.isEmpty())\n                throw new IllegalArgumentException(\"No resource options specified\");\n\n            for (String resourceName : resourceNames)\n                probe.invalidatePermissionsCache(roleName, resourceName);\n        }\n    }\n\n    private String constructFunctionResource(String functionsInKeyspace, String function) {\n        try\n        {\n            return FunctionResource.fromName(\"functions/\" + functionsInKeyspace + '/' + function).getName();\n        } catch (ConfigurationException e)\n        {\n            throw new IllegalArgumentException(\"An error was encountered when looking up function definition: \" + e.getMessage());\n        }\n    }\n}","sourceCodeStart":163,"sourceCodeEnd":184,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/InvalidatePermissionsCache.java#L163-L184","documentation":"constructFunctionResource resolves 'functions/<keyspace>/<function>' via FunctionResource.fromName; a ConfigurationException means the function or keyspace name is not a valid/existing resource name. The ConfigurationException is rethrown as IllegalArgumentException with this message.","triggerScenarios":"`nodetool invalidatepermissionscache --function <name> --functions-in-keyspace <ks>` where the function does not exist or the name contains invalid characters/overloaded signatures the parser cannot resolve.","commonSituations":"Typo in function name; function dropped before cache invalidation; wrong keyspace; function names with special characters needing escaping.","solutions":["Verify the function exists: SELECT function_name FROM system_schema.functions WHERE keyspace_name = '<ks>';","Correct the spelling of --function / --functions-in-keyspace","If the function was already dropped, invalidate the keyspace-level resource instead (--functions-in-keyspace alone)"],"exampleFix":"// before\nnodetool invalidatepermissionscache --function myfn --functions-in-keyspace wrong_ks\n// after\nnodetool invalidatepermissionscache --function myfn --functions-in-keyspace my_ks","handlingStrategy":"validation","validationCode":"const exists = await query(\"SELECT function_name FROM system_schema.functions WHERE keyspace_name = ? AND function_name = ?\", ks, fn);\nif (empty(exists)) throw new Error(`function ${ks}.${fn} not found`);","typeGuard":null,"tryCatchPattern":"try { runNodetool('invalidatepermissionscache', '--function', fn, '--functions-in-keyspace', ks); } catch (IllegalArgumentException e) { if (e.message.includes('looking up function definition')) { /* correct names */ } }","preventionTips":["Verify function and keyspace names against system_schema.functions first","Escape/special characters in function names","Fall back to --functions-in-keyspace level invalidation for dropped functions"],"tags":["cli","functions","resource-lookup"],"backgroundTag":"resource-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}