apache/cassandra · error · IllegalArgumentException
Can not parse replication factor %s
Error message
Can not parse replication factor %s
What it means
Nodetool's CMSAdmin (nodetool cms reconfigure) accepts replication factors of the form 'dc:rf'. If the argument contains more than one colon (more than 2 splits), it cannot be interpreted as a datacenter:replication-factor pair, so an IllegalArgumentException is thrown before any cluster operation starts.
Source
Thrown at src/java/org/apache/cassandra/tools/nodetool/CMSAdmin.java:188
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)));
}
parsedRfs.put(dc, parsedRf);
}
}
probe.getCMSOperationsProxy().reconfigureCMS(parsedRfs);
}
}
View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Pass replication factors as separate dc:rf pairs, e.g. `nodetool cms reconfigure dc1:3 dc2:5`, not a single colon-heavy string
- Quote arguments correctly in the shell so stray colons from variables are not concatenated
- Check `nodetool describecluster` for the actual DC names and format each as dc:integer
Example fix
// before nodetool cms reconfigure "dc1:3:dc2:5" // after nodetool cms reconfigure dc1:3 dc2:5
Defensive patterns
Strategy: validation
Validate before calling
String rf = args.get(0);
String[] splits = rf.split(":");
if (splits.length > 2 || splits.length < 2)
throw new IllegalArgumentException("expected dc:rf, got " + rf);
Integer.parseInt(splits[1]); // fail fast Try / catch
try { probe.getCMSOperationsProxy().reconfigureCMS(parsedRfs); }
catch (IllegalArgumentException e) { System.err.println("Bad RF spec: " + e.getMessage()); } Prevention
- Always pass dc:rf pairs, one per argument
- Quote shell variables to avoid unintended concatenation
- Verify DC names with nodetool describecluster
When it happens
Trigger: Running `nodetool cms reconfigure` with an RF argument containing multiple colons, e.g. `nodetool cms reconfigure dc1:5:extra` or a stray quoted string with colons.
Common situations: Typos when specifying per-DC RFs, accidentally passing a full option string, or pasting config snippets containing 'keyspace:dc:rf'-style values instead of the expected 'dc:rf' pair.
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 is empty
- Simple placement can only specify a single replication facto
- Specify snapshot name or --all
- Specify only one of snapshot name or --all
- Specify only one of --older-than or --older-than-timestamp
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/49ee801ab3867aba.
Report an issue: GitHub.