{"record":{"id":"66d1a34cb37d7488","repo":"apache/cassandra","slug":"invalid-number-of-arguments-for-function-s-66d1a3","errorCode":null,"errorMessage":"Invalid number of arguments for function %s","messagePattern":"Invalid number of arguments for function (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/masking/HashMaskingFunction.java","lineNumber":149,"sourceCode":"\n    /** @return a {@link FunctionFactory} to build new {@link HashMaskingFunction}s. */\n    public static FunctionFactory factory()\n    {\n        return new MaskingFunction.Factory(NAME,\n                                           FunctionParameter.anyType(false),\n                                           FunctionParameter.optional(FunctionParameter.fixed(CQL3Type.Native.TEXT)))\n        {\n            @Override\n            protected NativeFunction doGetOrCreateFunction(List<AbstractType<?>> argTypes, AbstractType<?> receiverType)\n            {\n                switch (argTypes.size())\n                {\n                    case 1:\n                        return new HashMaskingFunction(name, argTypes.get(0), false);\n                    case 2:\n                        return new HashMaskingFunction(name, argTypes.get(0), true);\n                    default:\n                        throw invalidNumberOfArgumentsException();\n                }\n            }\n        };\n    }\n}\n","sourceCodeStart":131,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/masking/HashMaskingFunction.java#L131-L155","documentation":"The built-in hash masking function factory (HashMaskingFunction.doGetOrCreateFunction) only accepts 1 or 2 arguments. Any other arity throws invalidNumberOfArgumentsException with message 'Invalid number of arguments for function %s'. The second argument toggles the salted/seeded variant.","triggerScenarios":"MASKED WITH hash(t1, t2, t3) with zero or three-plus arguments, e.g. hash(text, blob, int).","commonSituations":"Developer adds a hashing algorithm or seed as a third parameter, mistaking the signature for a general hash utility; the built-in hash only supports hash(type) and hash(type, seed/type).","solutions":["Reduce the argument list to one argument (the column type) or two arguments (column type plus salt/second parameter).","If a different hashing configuration is required, create a scalar UDF implementing the desired hashing and mask with that."],"exampleFix":"// before\nALTER TABLE users ALTER id MASKED WITH hash(int, blob, text);\n// after\nALTER TABLE users ALTER id MASKED WITH hash(int, blob);","handlingStrategy":"validation","validationCode":"if (fnName.equalsIgnoreCase(\"hash\") && (args.size() < 1 || args.size() > 2))\n  throw new IllegalArgumentException(\"hash masking accepts 1 or 2 arguments only\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember hash() supports only hash(type) and hash(type, salt) forms.","Implement additional hashing options as a UDF instead of overloading hash()."],"tags":["cql","masking","hash","arity"],"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"}