{"record":{"id":"d327cafa3e547a6c","repo":"apache/cassandra","slug":"value-of-name-size-has-to-be-strictly-positive-int","errorCode":null,"errorMessage":"Value of name_size has to be strictly positive integer.","messagePattern":"Value of name_size has to be strictly positive integer\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/guardrails/UUIDRoleNameGenerator.java","lineNumber":159,"sourceCode":"        }\n\n        return generatedValue;\n    }\n\n    private int getSize(Map<String, Object> options)\n    {\n        Object sizeObject;\n        if (options == null)\n        {\n            sizeObject = MAXIMUM_NAME_SIZE;\n        }\n        else if (options.containsKey(NAME_SIZE))\n        {\n            Object nameSizeValue = options.get(NAME_SIZE);\n            if (nameSizeValue != null)\n                sizeObject = nameSizeValue;\n            else\n                throw new IllegalArgumentException(\"Value of \" + NAME_SIZE + \" has to be strictly positive integer.\");\n        }\n        else\n        {\n            sizeObject = MAXIMUM_NAME_SIZE;\n        }\n\n        int size;\n\n        if (sizeObject instanceof String)\n        {\n            try\n            {\n                size = Integer.parseInt((String) sizeObject);\n            }\n            catch (Throwable t)\n            {\n                throw new IllegalArgumentException(\"Value '\" + sizeObject + \"' can't be converted to integer.\");\n            }","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/guardrails/UUIDRoleNameGenerator.java#L141-L177","documentation":"Thrown by UUIDRoleNameGenerator.getSize() when the 'name_size' key is present in the options map but its value is null. A null name_size is treated as invalid rather than falling back to the default maximum size.","triggerScenarios":"Calling generate(options) with options containing key name_size mapped to null — commonly from config like 'name_size:' with no value, or options.put(\"name_size\", null).","commonSituations":"YAML configs where an empty value deserializes to null; template variables that were not substituted.","solutions":["Omit the name_size key entirely if you want the default (MAXIMUM_NAME_SIZE)","Provide a strictly positive integer value (as a string or Number) for name_size","Sanitize the options map to drop null-valued entries before calling generate"],"exampleFix":"// before\noptions.put(\"name_size\", null);\n// after\noptions.remove(\"name_size\"); // falls back to MAXIMUM_NAME_SIZE\n// or\noptions.put(\"name_size\", \"8\");","handlingStrategy":"type-guard","validationCode":"if (options.containsKey(\"name_size\") && options.get(\"name_size\") == null)\n    options.remove(\"name_size\"); // fall back to MAXIMUM_NAME_SIZE","typeGuard":"boolean nameSizePresentAndNonNull(Map<String,Object> options) {\n    return options.containsKey(\"name_size\") && options.get(\"name_size\") != null;\n}","tryCatchPattern":"try {\n    generator.generate(options);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"name_size has to be strictly positive integer\")) {\n        // remove the null key (default applies) or set a positive integer and retry\n    } else throw e;\n}","preventionTips":["Omit name_size entirely instead of setting it to null","Normalize configs: replace empty YAML values with omission, not null","Validate strictly positive integer before passing name_size"],"tags":["guardrails","null","options","configuration"],"backgroundTag":"missing-config-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}