{"record":{"id":"4ad5ad3accec47fe","repo":"apache/cassandra","slug":"unable-to-parse-token-range-from-format-is-left","errorCode":null,"errorMessage":"Unable to parse token range from ; format is left,right but saw  parts","messagePattern":"Unable to parse token range from ; format is left,right but saw  parts","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/StandaloneVerifier.java","lineNumber":309,"sourceCode":"            header.append(\"--\\n\");\n            header.append(\"Verify the sstable for the provided table.\" );\n            header.append(\"\\n--\\n\");\n            header.append(\"NOTE: There are significant risks associated with using this tool; it likely doesn't do what \" +\n                          \"you expect and there are known edge cases. You must provide a -f or --force argument in \" +\n                          \"order to allow usage of the tool -> see CASSANDRA-9947 and CASSANDRA-17017 for known risks.\\n\");\n            header.append(\"https://issues.apache.org/jira/browse/CASSANDRA-9947\\n\");\n            header.append(\"https://issues.apache.org/jira/browse/CASSANDRA-17017\");\n            header.append(\"\\n--\\n\");\n            header.append(\"Options are:\");\n            new HelpFormatter().printHelp(usage, header.toString(), options, \"\");\n        }\n    }\n\n    private static Range<Token> parseTokenRange(String line)\n    {\n        String[] split = line.split(\",\");\n        if (split.length != 2)\n            throw new IllegalArgumentException(\"Unable to parse token range from \" + line + \"; format is left,right but saw \" + split.length + \" parts\");\n        long left = Long.parseLong(split[0]);\n        long right = Long.parseLong(split[1]);\n        return new Range<>(new Murmur3Partitioner.LongToken(left), new Murmur3Partitioner.LongToken(right));\n    }\n}\n","sourceCodeStart":291,"sourceCodeEnd":315,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/StandaloneVerifier.java#L291-L315","documentation":"StandaloneVerifier's offline verification tool accepts a --token-range CLI argument that must be two comma-separated longs forming a token range. parseTokenRange splits on ',' and throws IllegalArgumentException when the split does not yield exactly 2 parts, i.e. the user supplied zero, one, or more-than-two comma-separated values.","triggerScenarios":"Running standalone_verifier (or calling StandaloneVerifier.parseTokenRange) with a --token-range argument like '123', '1,2,3', an empty string, or one containing spaces/newlines that split into != 2 parts.","commonSituations":"Hand-typing a range with a semicolon or space instead of a comma; copying a range rendered as 'left:right'; accidentally passing multiple ranges 'a,b c,d'; shell stripping the trailing value leaving '123,'.","solutions":["Pass exactly two comma-separated long tokens, e.g. --token-range 123456789,987654321","Quote the argument in the shell so commas/spaces survive, e.g. --token-range \"123,456\"","Inspect the input for stray spaces or extra commas (split(',') counts empty parts); trim before passing"],"exampleFix":"// before\n--token-range 123:456\n// after\n--token-range 123,456","handlingStrategy":"validation","validationCode":"String[] parts = tokenRange.split(\",\");\nif (parts.length != 2)\n    throw new IllegalArgumentException(\"--token-range must be 'left,right', got: \" + tokenRange);\nLong.parseLong(parts[0].trim());\nLong.parseLong(parts[1].trim());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass exactly two comma-separated longs","Quote range arguments in the shell","Trim whitespace before splitting"],"tags":["cli","argument-parsing","offline-tools"],"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-17T15:17:12.973Z"}