{"record":{"id":"e88cf266ae3240c3","repo":"apache/cassandra","slug":"can-not-parse-replication-factor-from-s","errorCode":null,"errorMessage":"Can not parse replication factor from %s","messagePattern":"Can not parse replication factor from (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/CMSAdmin.java","lineNumber":179,"sourceCode":"\n            if (args.isEmpty())\n                throw new IllegalArgumentException(\"Replication factor is empty\");\n\n            Map<String, Integer> parsedRfs = new HashMap<>(args.size());\n            for (String rf : args)\n            {\n                if (!rf.contains(\":\"))\n                {\n                    if (args.size() > 1)\n                        throw new IllegalArgumentException(\"Simple placement can only specify a single replication factor across all data centers\");\n                    int parsedRf;\n                    try\n                    {\n                        parsedRf = Integer.parseInt(args.get(0));\n                    }\n                    catch (Throwable t)\n                    {\n                        throw new IllegalArgumentException(String.format(\"Can not parse replication factor from %s\", args.get(0)));\n                    }\n                    probe.getCMSOperationsProxy().reconfigureCMS(parsedRf);\n                    return;\n                }\n                else\n                {\n                    String[] splits = rf.split(\":\");\n                    if (splits.length > 2)\n                        throw new IllegalArgumentException(String.format(\"Can not parse replication factor %s\", rf));\n                    String dc = splits[0];\n                    int parsedRf;\n                    try\n                    {\n                        parsedRf = Integer.parseInt(splits[1]);\n                    }\n                    catch (Throwable t)\n                    {\n                        throw new IllegalArgumentException(String.format(\"Can not parse replication factor from %s\", args.get(0)));","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/CMSAdmin.java#L161-L197","documentation":"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.","triggerScenarios":"Running 'nodetool cms three', 'nodetool cms 3.5', or 'nodetool cms \" 3\"' — the single argument without ':' that is not a valid integer.","commonSituations":"Typos or letters in the RF; shell quoting adding whitespace; pasting 'dc1=3' style syntax; locales/scripts passing decimal numbers.","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"],"exampleFix":"// before\nnodetool cms 3.5\n// after\nnodetool cms 3","handlingStrategy":"validation","validationCode":"String arg = args[0].trim();\nif (!arg.matches(\"\\\\d+\"))\n    throw new IllegalArgumentException(\"RF must be a plain integer, got: \" + args[0]);\nint rf = Integer.parseInt(arg);","typeGuard":null,"tryCatchPattern":"try {\n    int rf = Integer.parseInt(args.get(0));\n} catch (NumberFormatException e) {\n    // show usage with valid RF examples\n}","preventionTips":["RF must be a plain non-negative integer","Trim whitespace and avoid decimal points","Use dc:rf syntax when DC names are intended"],"tags":["nodetool","cli","cms","number-parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}