apache/cassandra · error · InvalidRequestException

In this context function name must be explictly qualified by

Error message

In this context function name must be explictly qualified by a keyspace

What it means

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.

Source

Thrown at src/java/org/apache/cassandra/auth/FunctionResource.java:159

    {
        return new FunctionResource(function.name().keyspace, function.name().name, function.argTypes());
    }

    /**
     * Creates a FunctionResource representing a specific, keyspace-scoped function.
     * This variant is used to create an instance during parsing of a CQL statement.
     * It includes transposition of the arg types from CQL types to AbstractType
     * implementations
     *
     * @param keyspace the keyspace in which the function is scoped
     * @param name     name of the function.
     * @param argTypes the types of the function arguments in raw CQL form
     * @return FunctionResource instance reresenting the function.
     */
    public static FunctionResource functionFromCql(String keyspace, String name, List<CQL3Type.Raw> argTypes)
    {
        if (keyspace == null)
            throw new InvalidRequestException("In this context function name must be " +
                                              "explictly qualified by a keyspace");
        List<AbstractType<?>> abstractTypes = new ArrayList<>(argTypes.size());
        for (CQL3Type.Raw cqlType : argTypes)
            abstractTypes.add(cqlType.prepare(keyspace).getType().udfType());

        return new FunctionResource(keyspace, name, abstractTypes);
    }

    public static FunctionResource functionFromCql(FunctionName name, List<CQL3Type.Raw> argTypes)
    {
        return functionFromCql(name.keyspace, name.name, argTypes);
    }

    /**
     * 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

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Qualify the function name with its keyspace: 'ON FUNCTION <keyspace>.<name>(<types>)'
  2. Or first issue 'USE <keyspace>' in the same session so the keyspace is resolved
  3. If calling programmatically (AuthPermissions/RoleManager style code), pass a non-null keyspace string to functionFromCql

Example fix

// before
GRANT EXECUTE ON FUNCTION total(int) TO role1;
// after
GRANT EXECUTE ON FUNCTION mykeyspace.total(int) TO role1;
Defensive patterns

Strategy: validation

Validate before calling

if (keyspace == null || keyspace.isEmpty())
    throw new IllegalArgumentException("Function name in GRANT/REVOKE must be keyspace-qualified: <ks>.<fn>");

Try / catch

try { ... } catch (InvalidRequestException e) { /* prompt user to qualify the function with a keyspace */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/3659efd8ef6836df. Report an issue: GitHub.