{"record":{"id":"185de8e2f494ca89","repo":"apache/cassandra","slug":"user-defined-functions-are-disabled-in-cassandra-y","errorCode":null,"errorMessage":"User-defined functions are disabled in cassandra.yaml - set user_defined_functions_enabled=true to enable","messagePattern":"User-defined functions are disabled in cassandra\\.yaml - set user_defined_functions_enabled=true to enable","errorType":"exception","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/UDFunction.java","lineNumber":440,"sourceCode":"            return result;\n        }\n        catch (InvalidRequestException e)\n        {\n            throw e;\n        }\n        catch (Throwable t)\n        {\n            logger.debug(\"Invocation of user-defined function '{}' failed\", this, t);\n            if (t instanceof VirtualMachineError)\n                throw (VirtualMachineError) t;\n            throw FunctionExecutionException.create(this, t);\n        }\n    }\n\n    public static void assertUdfsEnabled(String language)\n    {\n        if (!DatabaseDescriptor.enableUserDefinedFunctions())\n            throw new InvalidRequestException(\"User-defined functions are disabled in cassandra.yaml - set user_defined_functions_enabled=true to enable\");\n        if (!\"java\".equalsIgnoreCase(language))\n            throw new InvalidRequestException(\"Currently only Java UDFs are available in Cassandra. For more information - CASSANDRA-18252 and CASSANDRA-17281\");\n    }\n\n    static void initializeThread()\n    {\n        // Get the TypeCodec stuff in Java Driver initialized.\n        // This is to get the classes loaded outside of the restricted sandbox's security context of a UDF.\n        TypeCodec.inet().format(InetAddress.getLoopbackAddress());\n        TypeCodec.ascii().format(\"\");\n    }\n\n    private static final class ThreadIdAndCpuTime extends CompletableFuture<Object>\n    {\n        long threadId;\n        long cpuTime;\n\n        ThreadIdAndCpuTime()","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/UDFunction.java#L422-L458","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set user_defined_functions_enabled: true in cassandra.yaml and restart the node(s)","If UDFs are intentionally disabled, remove/avoid the UDF calls from queries and schema","Check the effective value via a config dump/nodtool to confirm the setting applied to all nodes"],"exampleFix":"// cassandra.yaml\n// before\nuser_defined_functions_enabled: false\n// after\nuser_defined_functions_enabled: true","handlingStrategy":"validation","validationCode":"// before using UDFs, check the effective config\nboolean udfsOn = DatabaseDescriptor.enableUserDefinedFunctions();\nif (!udfsOn) throw new IllegalStateException(\"enable user_defined_functions_enabled in cassandra.yaml first\");","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["Set user_defined_functions_enabled: true in cassandra.yaml on every node before deploying UDFs","Restart nodes after changing the config so DatabaseDescriptor picks it up","Document the flag in cluster runbooks; it is disabled by default"],"tags":["udf","configuration","feature-flag","cassandra-yaml"],"backgroundTag":"feature-not-enabled","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"}