{"record":{"id":"e99994dfb35d7b20","repo":"apache/cassandra","slug":"start-and-end-tokens-must-be-different","errorCode":null,"errorMessage":"Start and end tokens must be different.","messagePattern":"Start and end tokens must be different\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/repair/messages/RepairOption.java","lineNumber":92,"sourceCode":"    public static Set<Range<Token>> parseRanges(String rangesStr, IPartitioner partitioner)\n    {\n        if (rangesStr == null || rangesStr.isEmpty())\n            return Collections.emptySet();\n\n        Set<Range<Token>> ranges = new HashSet<>();\n        StringTokenizer tokenizer = new StringTokenizer(rangesStr, \",\");\n        while (tokenizer.hasMoreTokens())\n        {\n            String[] rangeStr = tokenizer.nextToken().split(\":\", 2);\n            if (rangeStr.length < 2)\n            {\n                continue;\n            }\n            Token parsedBeginToken = partitioner.getTokenFactory().fromString(rangeStr[0].trim());\n            Token parsedEndToken = partitioner.getTokenFactory().fromString(rangeStr[1].trim());\n            if (parsedBeginToken.equals(parsedEndToken))\n            {\n                throw new IllegalArgumentException(\"Start and end tokens must be different.\");\n            }\n            ranges.add(new Range<>(parsedBeginToken, parsedEndToken));\n        }\n        return ranges;\n    }\n\n    /**\n     * Construct RepairOptions object from given map of Strings.\n     * <p>\n     * Available options are:\n     *\n     * <table>\n     *     <caption>Repair Options</caption>\n     *     <thead>\n     *         <tr>\n     *             <th>key</th>\n     *             <th>value</th>\n     *             <th>default (when key not given)</th>","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/repair/messages/RepairOption.java#L74-L110","documentation":"RepairOption.parseRanges parses user-supplied token ranges of the form begin:end and throws IllegalArgumentException if begin and end tokens are equal, because Range(token,token) is an empty range and not a valid repair range (ranges are [start, end)).","triggerScenarios":"Calling nodetool repair with --ranges (or RepairOption.ranges()) where a range string has identical start and end tokens, e.g. `1:1`.","commonSituations":"Hand-written range lists in scripts; misunderstanding that (x,x) means the full ring instead of an empty range; automation generating degenerate range strings.","solutions":["Remove the degenerate range and provide distinct start/end tokens","To repair the full ring, omit range options entirely (defaults to local node's ranges)","Use proper wrap-around notation (minToken, token] for wrap-around coverage instead of x:x"],"exampleFix":"// before\nnodetool repair ks --ranges 1:1\n// after\nnodetool repair -pr ks  # or use distinct tokens like 1:100","handlingStrategy":"validation","validationCode":"for (String r : rangeSpecs) {\n    String[] parts = r.split(\":\");\n    if (parts.length == 2 && parts[0].trim().equals(parts[1].trim()))\n        throw new IllegalArgumentException(\"Degenerate range \" + r + \": start and end tokens must differ\");\n}","typeGuard":null,"tryCatchPattern":"try { RepairOption.parse(opts, partitioner); }\ncatch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Start and end tokens must be different\"))\n        logger.warn(\"Fix range arguments; drop degenerate ranges\", e);\n    else throw e;\n}","preventionTips":["Never emit x:x ranges in automation; drop them instead","Omit range options to repair full/local ranges","Deduplicate and sanity-check token range strings before repair"],"tags":["repair","tokens","range-parsing","validation"],"backgroundTag":"invalid-argument-value","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"}