{"record":{"id":"617ce56964beb5da","repo":"apache/cassandra","slug":"the-padding-argument-for-function-s-should-be-sin","errorCode":null,"errorMessage":"The padding argument for function %s should be single-character, but '%s' has %d characters.","messagePattern":"The padding argument for function (.+?) should be single-character, but '(.+?)' has (.+?) characters\\.","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/masking/PartialMaskingFunction.java","lineNumber":90,"sourceCode":"    private PartialMaskingFunction(FunctionName name,\n                                   Kind kind,\n                                   AbstractType<String> inputType,\n                                   boolean hasPaddingArgument)\n    {\n        super(name, inputType, inputType, argumentsType(hasPaddingArgument));\n\n        this.kind = kind;\n        this.inputType = inputType;\n\n        paddingArgumentDeserializer = (version, buffer) -> {\n\n            if (buffer == null || !hasPaddingArgument)\n                return null;\n\n            String arg = UTF8Type.instance.compose(buffer);\n            if (arg.length() != 1)\n            {\n                throw new InvalidRequestException(format(\"The padding argument for function %s should \" +\n                                                         \"be single-character, but '%s' has %d characters.\",\n                                                         name, arg, arg.length()));\n            }\n            return arg.charAt(0);\n        };\n    }\n\n    private static AbstractType<?>[] argumentsType(boolean hasPaddingArgument)\n    {\n        // The padding argument is optional, so we provide different signatures depending on whether it's present or not.\n        // Also, the padding argument should be a single character, but we don't have a data type for that, so we use\n        // a string-based argument. We will later validate on execution that the string argument is single-character.\n        return hasPaddingArgument\n               ? new AbstractType<?>[]{ Int32Type.instance, Int32Type.instance, UTF8Type.instance }\n               : new AbstractType<?>[]{ Int32Type.instance, Int32Type.instance };\n    }\n\n    @Override","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/masking/PartialMaskingFunction.java#L72-L108","documentation":"PartialMaskingFunction's padding argument (used for mask_inner/mask_outer) must be exactly one character. When building the function, the padding string argument is composed from its serialized buffer and validated; strings longer than one character throw this InvalidRequestException.","triggerScenarios":"Creating a masked column with a multi-character padding argument, e.g. mask_inner('email', 2, 3, '**') — the padding literal '**' has length 2 and is rejected.","commonSituations":"Users trying to blank fields with multi-character fillers like '***' or '<redacted>'; copying padding examples from other SQL dialects that allow multi-char masks.","solutions":["Pass exactly one character as the padding argument, e.g. '*'","Repeat the character manually if a wider mask is wanted (the function repeats it internally)","Use no padding argument at all to get the default masking character"],"exampleFix":"// before\nmask_inner(email, 2, 3, '**')\n// after\nmask_inner(email, 2, 3, '*')","handlingStrategy":"validation","validationCode":"String padding = \"*\";\nif (padding.length() != 1) throw new IllegalArgumentException(\"padding argument must be a single character\");","typeGuard":null,"tryCatchPattern":"try {\n    session.execute(maskDdl);\n} catch (InvalidRequestException e) {\n    if (e.getMessage().contains(\"should be single-character\")) {\n        // collapse padding to one char and retry\n    }\n}","preventionTips":["Always pass a single-character literal ('*', '#', 'X') as the padding argument","Remember the function repeats the character internally; don't pre-repeat it","Centralize mask function construction in helpers that enforce the single-char rule"],"tags":["cassandra","masking","invalid-request"],"backgroundTag":"invalid-argument-value","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"}