{"record":{"id":"3659efd8ef6836df","repo":"apache/cassandra","slug":"in-this-context-function-name-must-be-explictly-qu","errorCode":null,"errorMessage":"In this context function name must be explictly qualified by a keyspace","messagePattern":"In this context function name must be explictly qualified by a keyspace","errorType":"exception","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/auth/FunctionResource.java","lineNumber":159,"sourceCode":"    {\n        return new FunctionResource(function.name().keyspace, function.name().name, function.argTypes());\n    }\n\n    /**\n     * Creates a FunctionResource representing a specific, keyspace-scoped function.\n     * This variant is used to create an instance during parsing of a CQL statement.\n     * It includes transposition of the arg types from CQL types to AbstractType\n     * implementations\n     *\n     * @param keyspace the keyspace in which the function is scoped\n     * @param name     name of the function.\n     * @param argTypes the types of the function arguments in raw CQL form\n     * @return FunctionResource instance reresenting the function.\n     */\n    public static FunctionResource functionFromCql(String keyspace, String name, List<CQL3Type.Raw> argTypes)\n    {\n        if (keyspace == null)\n            throw new InvalidRequestException(\"In this context function name must be \" +\n                                              \"explictly qualified by a keyspace\");\n        List<AbstractType<?>> abstractTypes = new ArrayList<>(argTypes.size());\n        for (CQL3Type.Raw cqlType : argTypes)\n            abstractTypes.add(cqlType.prepare(keyspace).getType().udfType());\n\n        return new FunctionResource(keyspace, name, abstractTypes);\n    }\n\n    public static FunctionResource functionFromCql(FunctionName name, List<CQL3Type.Raw> argTypes)\n    {\n        return functionFromCql(name.keyspace, name.name, argTypes);\n    }\n\n    /**\n     * 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","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/auth/FunctionResource.java#L141-L177","documentation":"FunctionResource.functionFromCql builds a function-level permission resource from a CQL function signature. When the keyspace argument is null the function name is unqualified, and Cassandra refuses to guess the keyspace in that context, throwing InvalidRequestException.","triggerScenarios":"Executing GRANT/REVOKE/LIST PERMISSIONS on a function without a keyspace qualifier, e.g. 'GRANT EXECUTE ON FUNCTION myfn(int) TO role' instead of 'ON FUNCTION ks.myfn(int)', when the statement is not executed within a USE keyspace context that supplies a default.","commonSituations":"Copy-pasting function signatures from CREATE FUNCTION statements that omitted the keyspace; running auth statements from cqlsh without a keyspace selected; tools generating permission DDL from unqualified function names.","solutions":["Qualify the function name with its keyspace: 'ON FUNCTION <keyspace>.<name>(<types>)'","Or first issue 'USE <keyspace>' in the same session so the keyspace is resolved","If calling programmatically (AuthPermissions/RoleManager style code), pass a non-null keyspace string to functionFromCql"],"exampleFix":"// before\nGRANT EXECUTE ON FUNCTION total(int) TO role1;\n// after\nGRANT EXECUTE ON FUNCTION mykeyspace.total(int) TO role1;","handlingStrategy":"validation","validationCode":"if (keyspace == null || keyspace.isEmpty())\n    throw new IllegalArgumentException(\"Function name in GRANT/REVOKE must be keyspace-qualified: <ks>.<fn>\");","typeGuard":null,"tryCatchPattern":"try { ... } catch (InvalidRequestException e) { /* prompt user to qualify the function with a keyspace */ }","preventionTips":["Always write ON FUNCTION <keyspace>.<name>(<types>) in permission statements","Issue USE <keyspace> when running multiple auth statements in one session","Generate permission DDL from fully qualified FunctionName objects"],"tags":["cassandra","cql","auth","function-resource"],"backgroundTag":"missing-required-argument","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"}