{"record":{"id":"ead02b37bb9ef185","repo":"google/tsunami-security-scanner","slug":"invalid-range-of-versions-got-s","errorCode":null,"errorMessage":"Invalid range of versions, got '%s'","messagePattern":"Invalid range of versions, got '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/com/google/tsunami/common/version/VersionRange.java","lineNumber":152,"sourceCode":"    if (!rangeString.endsWith(\"]\") && !rangeString.endsWith(\")\")) {\n      throw new IllegalArgumentException(\n          String.format(\"Version range must end with ']' or ')', got '%s'\", rangeString));\n    }\n\n    // Remove the leading and ending parenthesis and brackets.\n    String trimmedRange = rangeString.substring(1, rangeString.length() - 1).trim();\n\n    // No more parenthesis and brackets in the string.\n    if (CharMatcher.anyOf(\"[()]\").matchesAnyOf(trimmedRange)) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Parenthesis and/or brackets not allowed within version range, got '%s'\",\n              rangeString));\n    }\n\n    // Only one comma that separates the minimum and maximum.\n    if (CharMatcher.is(',').countIn(trimmedRange) != 1) {\n      throw new IllegalArgumentException(\n          String.format(\"Invalid range of versions, got '%s'\", rangeString));\n    }\n\n    // Version range of minimum to maximum is not supported.\n    if (trimmedRange.equals(\",\")) {\n      throw new IllegalArgumentException(\n          String.format(\"Infinity range is not supported, got '%s'\", rangeString));\n    }\n  }\n}\n","sourceCodeStart":134,"sourceCodeEnd":163,"githubUrl":"https://github.com/google/tsunami-security-scanner/blob/363ba87b3543f8ae8e4304d3416818f03da7f262/common/src/main/java/com/google/tsunami/common/version/VersionRange.java#L134-L163","documentation":"VersionRange.parse requires exactly one comma separating the minimum and maximum bounds of the range. If the inner string contains zero commas or more than one, the range cannot be split into a min/max pair and this IllegalArgumentException is thrown.","triggerScenarios":"Calling VersionRange.parse with strings like \"[1.0]\" (no comma), \"[1.0,2.0,3.0]\" (two commas), or \"[1.0 2.0]\" after the bracket validation has passed.","commonSituations":"Typing a discrete version where a range is expected (\"[1.0.0]\" without comma), joining multiple ranges with commas instead of parsing them separately, or locale mistakes inserting extra separators.","solutions":["Ensure the range contains exactly one comma: \"[min,max]\" format.","Parse each range separately and combine with VersionSet instead of comma-joining multiple ranges.","If you only have a single version, use Version.fromString rather than a range."],"exampleFix":"// before\nVersionRange.parse(\"[1.0,2.0,3.0]\");\n// after\nVersionRange.parse(\"[1.0,2.0]\");","handlingStrategy":"validation","validationCode":"if (rangeString != null && rangeString.replaceAll(\"^[\\\\[\\\\(]|[\\\\]\\\\)]$\", \"\").trim().chars().filter(c -> c == ',').count() == 1) { VersionRange.parse(rangeString); }","typeGuard":"boolean hasSingleComma(String s) { return s != null && s.indexOf(',') == s.lastIndexOf(',') && s.indexOf(',') >= 0; }","tryCatchPattern":"try { VersionRange.parse(rangeString); } catch (IllegalArgumentException e) { log.error(\"Invalid range '{}'\", rangeString); }","preventionTips":["Always use [min,max] form with exactly one comma.","Do not comma-join multiple ranges; use VersionSet.","Reject single-version strings before treating them as ranges."],"tags":["version-range","parsing","illegal-argument"],"backgroundTag":"invalid-argument-format","analyzedSha":"363ba87b3543f8ae8e4304d3416818f03da7f262","analyzedAt":"2026-09-13T01:50:53.990Z","contentChangedAt":"2026-09-13T01:50:53.990Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}