{"record":{"id":"9fb0e7121ce16d76","repo":"apache/cassandra","slug":"value-of-s-cannot-be-null","errorCode":null,"errorMessage":"Value of %s cannot be null.","messagePattern":"Value of (.+?) cannot be null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/guardrails/UUIDRoleNameGenerator.java","lineNumber":132,"sourceCode":"\n    @Override\n    public void validateParameters() throws ConfigurationException\n    {\n        if (minimumNameSize < DEFAULT_MINIMUM_NAME_SIZE || minimumNameSize > MAXIMUM_NAME_SIZE)\n            throw new ConfigurationException(MINIMUM_NAME_SIZE_CONFIG_OPTION + \" has to be at least \" + DEFAULT_MINIMUM_NAME_SIZE + \" and at most \" + MAXIMUM_NAME_SIZE);\n    }\n\n    private String enrich(String key, String generatedValue, Map<String, Object> options)\n    {\n        if (options == null || options.isEmpty())\n            return generatedValue;\n\n        if (options.containsKey(key))\n        {\n            Object value = options.get(key);\n\n            if (value == null)\n                throw new IllegalArgumentException(\"Value of \" + key + \" cannot be null.\");\n\n            if (!(value instanceof String))\n                throw new IllegalArgumentException(\"Value of \" + key + \" is not a string.\");\n\n            if (NAME_PREFIX_KEY.equals(key))\n                generatedValue = value + generatedValue;\n            else if (NAME_SUFFIX_KEY.equals(key))\n                generatedValue = generatedValue + value;\n        }\n\n        return generatedValue;\n    }\n\n    private int getSize(Map<String, Object> options)\n    {\n        Object sizeObject;\n        if (options == null)\n        {","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/guardrails/UUIDRoleNameGenerator.java#L114-L150","documentation":"Thrown by UUIDRoleNameGenerator.enrich() when an options map passed to generate() contains a key (e.g. name_prefix, name_suffix, name_size) mapped to a null value. Prefix/suffix enrichment only accepts non-null string values, so nulls are rejected with IllegalArgumentException.","triggerScenarios":"Calling generate(options) with a map built programmatically that includes a key with a null value, e.g. options.put(\"name_prefix\", null), typically from unmarshalled config where a key exists but has no value.","commonSituations":"YAML/JSON config with 'name_prefix:' but no value deserialized as null; templating systems substituting an unset variable with null.","solutions":["Remove null-valued keys from the options map before calling generate","Default empty prefix/suffix to \"\" instead of null in your config layer","Check the message for the offending key name and provide a string value for it"],"exampleFix":"// before\nMap<String,Object> options = new HashMap<>();\noptions.put(\"name_prefix\", null);\n// after\nMap<String,Object> options = new HashMap<>();\noptions.put(\"name_prefix\", \"svc-\");","handlingStrategy":"type-guard","validationCode":"for (var e : options.entrySet())\n    if (e.getValue() == null)\n        throw new IllegalArgumentException(\"null value for option: \" + e.getKey());","typeGuard":"boolean hasNonNullStringValues(Map<String,Object> options) {\n    return options.values().stream().allMatch(v -> v instanceof String);\n}","tryCatchPattern":"try {\n    String name = generator.generate(options);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"cannot be null\")) {\n        // drop null-valued keys or substitute defaults, then retry\n    } else throw e;\n}","preventionTips":["Strip null-valued entries from the options map before calling generate","Default unset prefix/suffix to \"\" rather than null in your config layer","Never let unmarshalled YAML/JSON nulls flow into generator options"],"tags":["guardrails","arguments","null","options"],"backgroundTag":"null-argument","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"}