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

  1. Omit the name_size key entirely if you want the default (MAXIMUM_NAME_SIZE)
  2. Provide a strictly positive integer value (as a string or Number) for name_size
  3. 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

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


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/d327cafa3e547a6c. Report an issue: GitHub.