{"record":{"id":"d2e270e5836c0401","repo":"Grasscutters/Grasscutter","slug":"range-passed-minimum-higher-than-maximum","errorCode":null,"errorMessage":"Range passed minimum higher than maximum -  > ","messagePattern":"Range passed minimum higher than maximum -  > ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/emu/grasscutter/utils/objects/SparseSet.java","lineNumber":53,"sourceCode":"        for (Range range : this.rangeEntries) {\n            if (range.check(i)) {\n                return true;\n            }\n        }\n        return this.denseEntries.contains(i);\n    }\n\n    /*\n     * A convenience class for constructing integer sets out of large ranges\n     * Designed to be fed literal strings from this project only -\n     * can and will throw exceptions to tell you to fix your code if you feed it garbage. :)\n     */\n    private static class Range {\n        private final int min, max;\n\n        public Range(int min, int max) {\n            if (min > max) {\n                throw new IllegalArgumentException(\n                        \"Range passed minimum higher than maximum - \" + min + \" > \" + max);\n            }\n            this.min = min;\n            this.max = max;\n        }\n\n        public boolean check(int value) {\n            return value >= this.min && value <= this.max;\n        }\n    }\n}\n","sourceCodeStart":35,"sourceCodeEnd":65,"githubUrl":"https://github.com/Grasscutters/Grasscutter/blob/f373827a83d3e688fd3c6afb1e1c3759ca1d61c9/src/main/java/emu/grasscutter/utils/objects/SparseSet.java#L35-L65","documentation":"SparseSet's inner Range validates that min <= max; constructing a Range with min > max throws this IllegalArgumentException. It surfaces when a range token in a SparseSet initializer is written in descending order, e.g. '50-10'.","triggerScenarios":"new SparseSet(\"50-10\") or any token where the first integer is greater than the second; the exception message shows the two parsed values, e.g. 'Range passed minimum higher than maximum - 50 > 10'.","commonSituations":"Hand-written range specs with swapped endpoints; generated specs from unsorted data; typos when editing id exclusion/include lists.","solutions":["Swap the endpoints in the spec so it reads smaller-largest, e.g. '10-50' instead of '50-10'","Sort range endpoints in any generator that emits SparseSet specs","If ranges must be accepted either way, normalize at parse time by using Math.min/Math.max before constructing Range"],"exampleFix":"// before\nnew SparseSet(\"100-50\");\n// after\nnew SparseSet(\"50-100\");","handlingStrategy":"validation","validationCode":"void validateRangeOrder(String spec) {\n  for (String token : spec.split(\",\")) {\n    String[] p = token.split(\"-\");\n    if (p.length == 2 && Integer.parseInt(p[0]) > Integer.parseInt(p[1]))\n      throw new IllegalArgumentException(\"Descending range: \" + token);\n  }\n}","typeGuard":"boolean isAscendingRange(String token) {\n  String[] p = token.split(\"-\");\n  return p.length != 2 || Integer.parseInt(p[0]) <= Integer.parseInt(p[1]);\n}","tryCatchPattern":"try {\n  SparseSet set = new SparseSet(spec);\n} catch (IllegalArgumentException e) {\n  logger.error(\"Range order problem: {}\", e.getMessage());\n}","preventionTips":["Always write ranges ascending: smaller value first","Sort endpoints in generators before emitting 'min-max' tokens","Normalize with Math.min/Math.max if input order is uncontrolled","Spot-check hand-edited range specs before loading"],"tags":["parsing","illegal-argument","range","sparse-set"],"backgroundTag":"invalid-range-specifier","analyzedSha":"f373827a83d3e688fd3c6afb1e1c3759ca1d61c9","analyzedAt":"2026-09-03T22:43:49.407Z","contentChangedAt":"2026-09-03T22:43:49.407Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}