apache/cassandra · error · IllegalArgumentException
Can not parse replication factor from %s
Error message
Can not parse replication factor from %s
What it means
When a single plain-string RF argument is given to nodetool cms, it is parsed with Integer.parseInt; failure to parse produces IllegalArgumentException('Can not parse replication factor from %s') naming the offending argument.
Source
Thrown at src/java/org/apache/cassandra/tools/nodetool/CMSAdmin.java:179
if (args.isEmpty())
throw new IllegalArgumentException("Replication factor is empty");
Map<String, Integer> parsedRfs = new HashMap<>(args.size());
for (String rf : args)
{
if (!rf.contains(":"))
{
if (args.size() > 1)
throw new IllegalArgumentException("Simple placement can only specify a single replication factor across all data centers");
int parsedRf;
try
{
parsedRf = Integer.parseInt(args.get(0));
}
catch (Throwable t)
{
throw new IllegalArgumentException(String.format("Can not parse replication factor from %s", args.get(0)));
}
probe.getCMSOperationsProxy().reconfigureCMS(parsedRf);
return;
}
else
{
String[] splits = rf.split(":");
if (splits.length > 2)
throw new IllegalArgumentException(String.format("Can not parse replication factor %s", rf));
String dc = splits[0];
int parsedRf;
try
{
parsedRf = Integer.parseInt(splits[1]);
}
catch (Throwable t)
{
throw new IllegalArgumentException(String.format("Can not parse replication factor from %s", args.get(0)));View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Pass a plain positive integer: nodetool cms 3
- Trim whitespace and remove stray characters from the argument
- Use dc:rf syntax if you meant per-DC factors: nodetool cms dc1:3
Example fix
// before nodetool cms 3.5 // after nodetool cms 3
Defensive patterns
Strategy: validation
Validate before calling
String arg = args[0].trim();
if (!arg.matches("\\d+"))
throw new IllegalArgumentException("RF must be a plain integer, got: " + args[0]);
int rf = Integer.parseInt(arg); Try / catch
try {
int rf = Integer.parseInt(args.get(0));
} catch (NumberFormatException e) {
// show usage with valid RF examples
} Prevention
- RF must be a plain non-negative integer
- Trim whitespace and avoid decimal points
- Use dc:rf syntax when DC names are intended
When it happens
Trigger: Running 'nodetool cms three', 'nodetool cms 3.5', or 'nodetool cms " 3"' — the single argument without ':' that is not a valid integer.
Common situations: Typos or letters in the RF; shell quoting adding whitespace; pasting 'dc1=3' style syntax; locales/scripts passing decimal numbers.
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
- Replication factor should not be set if previous operation i
- Replication factor is empty
- Simple placement can only specify a single replication facto
- Failed to initialize command line hierarchy
- Unknown CLI layout:
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/e88cf266ae3240c3.
Report an issue: GitHub.