apache/cassandra · error · IllegalArgumentException
Value '%s' can't be converted to integer.
Error message
Value '%s' can't be converted to integer.
What it means
Thrown by UUIDRoleNameGenerator.getSize() when the 'name_size' option is a String that Integer.parseInt cannot convert (or a completely unsupported object type). The message includes the offending value.
Source
Thrown at src/java/org/apache/cassandra/db/guardrails/UUIDRoleNameGenerator.java:176
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.");
}
}
else if (sizeObject instanceof Number)
size = ((Number) sizeObject).intValue();
else
throw new IllegalArgumentException("Unsupported object passed to resolve " + NAME_SIZE + ": " + sizeObject.getClass().getName());
if (size < minimumNameSize)
throw new IllegalArgumentException("Value of " + NAME_SIZE + " parameter has to be at least " + minimumNameSize + '.');
if (size > MAXIMUM_NAME_SIZE)
throw new IllegalArgumentException("Generator generates names of maximum length " + MAXIMUM_NAME_SIZE + ". " +
"You want to generate with length " + size + '.');
return size;
}
}
View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Pass name_size as a whole-number string like "8" or as an integer Number type
- Trim whitespace and avoid decimals/suffixes in the string value
- Handle the unsupported-type branch: only String or Number instances are accepted
Example fix
// before
options.put("name_size", "8.5");
// after
options.put("name_size", "8"); Defensive patterns
Strategy: validation
Validate before calling
Object v = options.get("name_size");
if (v instanceof String s && !s.trim().matches("\\d+"))
throw new IllegalArgumentException("name_size must be a whole number string"); Type guard
boolean isParsableSize(Object v) {
if (v instanceof Number) return true;
if (v instanceof String) try { Integer.parseInt((String) v); return true; } catch (Exception e) { return false; }
return false;
} Try / catch
try {
generator.generate(options);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("can't be converted to integer")) {
// parse/normalize name_size client-side, then retry
} else throw e;
} Prevention
- Pass name_size as "8" (integer string) or as an Integer, never "8.0" or " 8"
- Trim and regex-validate numeric strings before passing
- Reject non-numeric strings at config-load time
When it happens
Trigger: Passing name_size as a non-numeric string like "eight" or "8.5" or " 8" (whitespace), or as an unsupported object (e.g. Boolean, List) that is neither String nor Number.
Common situations: Users writing fractional or formatted numbers ('8.0', '1_0'), or config frameworks deserializing the value as a Float/Boolean.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Value of %s is not a string.
- Unsupported object passed to resolve name_size: %s
- Value of %s cannot be null.
- Unexpected string: ${tokenScanner.next()}
- Unhandled return type:
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/6f5541acc591dd71.
Report an issue: GitHub.