apache/cassandra · error · InvalidRequestException

User-defined functions are disabled in cassandra.yaml - set…

Error message

User-defined functions are disabled in cassandra.yaml - set user_defined_functions_enabled=true to enable

What it means

UDFunction.assertUdfsEnabled rejects UDF creation/execution when user_defined_functions_enabled is false in cassandra.yaml (DatabaseDescriptor.enableUserDefinedFunctions() returns false). Cassandra disables Java UDFs by default for security and sandboxing reasons.

Solutions

  1. Set user_defined_functions_enabled: true in cassandra.yaml and restart the node(s)
  2. If UDFs are intentionally disabled, remove/avoid the UDF calls from queries and schema
  3. Check the effective value via a config dump/nodtool to confirm the setting applied to all nodes

Example fix

// cassandra.yaml
// before
user_defined_functions_enabled: false
// after
user_defined_functions_enabled: true
Defensive patterns

Strategy: validation

Validate before calling

// before using UDFs, check the effective config
boolean udfsOn = DatabaseDescriptor.enableUserDefinedFunctions();
if (!udfsOn) throw new IllegalStateException("enable user_defined_functions_enabled in cassandra.yaml first");

Try / catch

try { session.execute("SELECT f(x) FROM t ..."); } catch (InvalidRequestException e) { if (e.getMessage().contains("disabled")) { /* guide operator to set user_defined_functions_enabled=true */ } throw e; }

Prevention

When it happens

Trigger: CREATE FUNCTION / CREATE AGGREGATE, or executing a query that invokes a UDF (execute, executeForAggregate), while user_defined_functions_enabled is not set to true in cassandra.yaml.

Common situations: Fresh install or upgrade where UDFs are disabled by default; cluster where the operator deliberately disabled UDFs; calling a UDF created on a cluster where the flag was later turned off.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/functions/UDFunction.java:440

            return result;
        }
        catch (InvalidRequestException e)
        {
            throw e;
        }
        catch (Throwable t)
        {
            logger.debug("Invocation of user-defined function '{}' failed", this, t);
            if (t instanceof VirtualMachineError)
                throw (VirtualMachineError) t;
            throw FunctionExecutionException.create(this, t);
        }
    }

    public static void assertUdfsEnabled(String language)
    {
        if (!DatabaseDescriptor.enableUserDefinedFunctions())
            throw new InvalidRequestException("User-defined functions are disabled in cassandra.yaml - set user_defined_functions_enabled=true to enable");
        if (!"java".equalsIgnoreCase(language))
            throw new InvalidRequestException("Currently only Java UDFs are available in Cassandra. For more information - CASSANDRA-18252 and CASSANDRA-17281");
    }

    static void initializeThread()
    {
        // Get the TypeCodec stuff in Java Driver initialized.
        // This is to get the classes loaded outside of the restricted sandbox's security context of a UDF.
        TypeCodec.inet().format(InetAddress.getLoopbackAddress());
        TypeCodec.ascii().format("");
    }

    private static final class ThreadIdAndCpuTime extends CompletableFuture<Object>
    {
        long threadId;
        long cpuTime;

        ThreadIdAndCpuTime()

View on GitHub (pinned to 88fd0f6a0e)