{"record":{"id":"36e250eef18d4cde","repo":"apache/cassandra","slug":"unable-to-find-masking-function-for-s-no-declare","errorCode":null,"errorMessage":"Unable to find masking function for %s, no declared function matches the signature %s","messagePattern":"Unable to find masking function for (.+?), no declared function matches the signature (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/masking/ColumnMask.java","lineNumber":245,"sourceCode":"        }\n\n        public ColumnMask prepare(String keyspace, String table, ColumnIdentifier column, AbstractType<?> type, UserFunctions functions)\n        {\n            ScalarFunction function = findMaskingFunction(keyspace, table, column, type, functions);\n            ByteBuffer[] partialArguments = preparePartialArguments(keyspace, function);\n            return new ColumnMask(function, partialArguments);\n        }\n\n        private ScalarFunction findMaskingFunction(String keyspace, String table, ColumnIdentifier column, AbstractType<?> type, UserFunctions functions)\n        {\n            List<AssignmentTestable> args = new ArrayList<>(rawPartialArguments.size() + 1);\n            args.add(type);\n            args.addAll(rawPartialArguments);\n\n            Function function = FunctionResolver.get(keyspace, name, args, keyspace, table, type, functions);\n\n            if (function == null)\n                throw invalidRequest(\"Unable to find masking function for %s, \" +\n                                     \"no declared function matches the signature %s\",\n                                     column, this);\n\n            if (function.isAggregate())\n                throw invalidRequest(\"Aggregate function %s cannot be used for masking table columns\", this);\n\n            if (function.isNative() && !(function instanceof MaskingFunction))\n                throw invalidRequest(\"Not-masking function %s cannot be used for masking table columns\", this);\n\n            if (!function.isNative() && !function.name().keyspace.equals(keyspace))\n                throw invalidRequest(\"Masking function %s doesn't belong to the same keyspace as the table %s.%s\",\n                                     this, keyspace, table);\n\n            CQL3Type returnType = function.returnType().asCQL3Type();\n            CQL3Type expectedType = type.asCQL3Type();\n            if (!returnType.equals(expectedType))\n                throw invalidRequest(\"Masking function %s return type is %s. \" +\n                                     \"This is different to the type of the masked column %s of type %s. \" +","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/masking/ColumnMask.java#L227-L263","documentation":"Thrown by ColumnMask.findMaskingFunction when a MASKED WITH function reference cannot be resolved to any declared function matching the given name and argument types. FunctionResolver.get returned null, meaning no native or user-defined function exists with that signature. Cassandra refuses to attach the masking policy because there is no function to apply.","triggerScenarios":"Executing CREATE TABLE ... col type MASKED WITH <name>(args) or ALTER TABLE ... MASKED WITH, where the function name is misspelled, the function does not exist in the keyspace, or the argument types/count do not match any declared overload.","commonSituations":"Typo in the masking function name (e.g. mask_null vs mask_null()), referencing a UDF that was created in a different keyspace without qualification, passing wrong argument arity to a built-in masking function, or running against a cluster where dynamic data masking (CE-3.0 feature) functions are unavailable.","solutions":["Verify the exact masking function name and argument signature against the built-ins in org.apache.cassandra.cql3.functions.masking (MaskingFunction, HashMaskingFunction, etc.) and fix the MASKED WITH clause.","Qualify the function with its keyspace (keyspace.funcName) if it is a user-defined masking function and check it exists via SELECT from system_schema.functions.","Confirm the argument count and types match a declared overload; use DESCRIBE FUNCTION or cqlsh to inspect available signatures."],"exampleFix":"// before\nCREATE TABLE users (email text MASKED WITH bogus_mask(text));\n// after\nCREATE TABLE users (email text MASKED WITH mask_null(text));","handlingStrategy":"validation","validationCode":"// check function exists before DDL\nRow r = session.execute(\"SELECT function_name FROM system_schema.functions WHERE keyspace_name=? AND function_name=?\", ks, fn).one();\nif (r == null) throw new IllegalStateException(\"masking function not found: \" + fn);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a checked-in list of approved masking function signatures per column type.","Always fully-qualify UDF masking functions with the keyspace.","Test masked-column DDL in a staging keyspace before production."],"tags":["cql","masking","function-resolution","invalid-argument"],"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"}