apache/cassandra · error · IllegalArgumentException
Value of name_size has to be strictly positive integer.
Error message
Value of name_size has to be strictly positive integer.
What it means
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.
Source
Thrown at src/java/org/apache/cassandra/db/guardrails/UUIDRoleNameGenerator.java:159
}
return generatedValue;
}
private int getSize(Map<String, Object> options)
{
Object sizeObject;
if (options == null)
{
sizeObject = MAXIMUM_NAME_SIZE;
}
else if (options.containsKey(NAME_SIZE))
{
Object nameSizeValue = options.get(NAME_SIZE);
if (nameSizeValue != null)
sizeObject = nameSizeValue;
else
throw new IllegalArgumentException("Value of " + NAME_SIZE + " has to be strictly positive integer.");
}
else
{
sizeObject = MAXIMUM_NAME_SIZE;
}
int size;
if (sizeObject instanceof String)
{
try
{
size = Integer.parseInt((String) sizeObject);
}
catch (Throwable t)
{
throw new IllegalArgumentException("Value '" + sizeObject + "' can't be converted to integer.");
}View on GitHub (pinned to 88fd0f6a0e)
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
Example fix
// before
options.put("name_size", null);
// after
options.remove("name_size"); // falls back to MAXIMUM_NAME_SIZE
// or
options.put("name_size", "8"); Defensive patterns
Strategy: type-guard
Validate before calling
if (options.containsKey("name_size") && options.get("name_size") == null)
options.remove("name_size"); // fall back to MAXIMUM_NAME_SIZE Type guard
boolean nameSizePresentAndNonNull(Map<String,Object> options) {
return options.containsKey("name_size") && options.get("name_size") != null;
} Try / catch
try {
generator.generate(options);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("name_size has to be strictly positive integer")) {
// remove the null key (default applies) or set a positive integer and retry
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: YAML configs where an empty value deserializes to null; template variables that were not substituted.
Understand the failure class
Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.
Related errors
- Value of %s cannot be null.
- Value of name_size parameter has to be at least %s.
- Generator generates names of maximum length %s. You want to
- Invalid guardrails configuration:
- default_keyspace_rf to be set (%d) cannot be less than minim
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/d327cafa3e547a6c.
Report an issue: GitHub.