{"record":{"id":"2ef2c2cefcbf86e1","repo":"apache/cassandra","slug":"invalid-version-value-version-part-not-a-v","errorCode":null,"errorMessage":"Invalid version value: ${version}; ${part} not a valid identifier","messagePattern":"Invalid version value: (.+?); (.+?) not a valid identifier","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/utils/CassandraVersion.java","lineNumber":151,"sourceCode":"        String value = matcher.group(group);\n        return value == null ? orElse : Integer.parseInt(value);\n    }\n\n    private CassandraVersion getFamilyLowerBound()\n    {\n        return patch == 0 && hotfix == NO_HOTFIX && preRelease != null && preRelease.length == 0 && build == null\n               ? this\n               : new CassandraVersion(major, minor, 0, NO_HOTFIX, ArrayUtils.EMPTY_STRING_ARRAY, null);\n    }\n\n    private static String[] parseIdentifiers(String version, String str)\n    {\n        // Drop initial - or +\n        String[] parts = StringUtils.split(str, \".-\");\n        for (String part : parts)\n        {\n            if (!PATTERN_WORDS.matcher(part).matches())\n                throw new IllegalArgumentException(\"Invalid version value: \" + version + \"; \" + part + \" not a valid identifier\");\n        }\n        return parts;\n    }\n\n    public List<String> getPreRelease()\n    {\n        return preRelease != null ? Arrays.asList(preRelease) : Collections.emptyList();\n    }\n\n    public List<String> getBuild()\n    {\n        return build != null ? Arrays.asList(build) : Collections.emptyList();\n    }\n\n    public int compareTo(CassandraVersion other)\n    {\n        return compareTo(other, false);\n    }","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/utils/CassandraVersion.java#L133-L169","documentation":"parseIdentifiers splits the pre-release/build portion of a version string on '.-' and validates each identifier against PATTERN_WORDS (alphanumeric tokens). If any segment contains disallowed characters, an IllegalArgumentException names the offending part.","triggerScenarios":"new CassandraVersion(\"1.2.3-beta_1\") or \"1.2.3+build#7\" — any pre-release/build identifier with characters outside [0-9A-Za-z] (hyphens separate tokens, dots delimit them).","commonSituations":"Version strings with underscores, spaces, or shell-special characters supplied in config or by CI tooling; converting from other versioning schemes (e.g. '1.2.3_beta') directly to CassandraVersion.","solutions":["Sanitize the version string so each pre-release/build segment matches word characters, e.g. 'beta_1' -> 'beta1' or 'beta-1'","Replace illegal separators (underscores, '#', spaces) with '.' or '-' before constructing","Catch IllegalArgumentException and validate user-supplied versions with the same regex before passing them in"],"exampleFix":"// before\nnew CassandraVersion(\"4.0.0-beta_1\");\n// after\nnew CassandraVersion(\"4.0.0-beta.1\");","handlingStrategy":"validation","validationCode":"boolean validIdentifiers(String version) {\n    int plus = version.indexOf('+');\n    String tail = plus >= 0 ? version.substring(plus + 1)\n                : version.contains(\"-\") ? version.substring(version.indexOf('-') + 1) : \"\";\n    return java.util.Arrays.stream(tail.split(\"[.-]\"))\n        .allMatch(p -> p.matches(\"[0-9A-Za-z]+\"));\n}","typeGuard":null,"tryCatchPattern":"try {\n    CassandraVersion v = new CassandraVersion(version);\n} catch (IllegalArgumentException e) {\n    // e.getMessage() names the offending identifier\n    throw new ConfigurationException(\"Unsupported version: \" + version, e);\n}","preventionTips":["Use only [0-9A-Za-z] tokens separated by '.' or '-' in pre-release/build parts","Normalize other versioning schemes (underscores etc.) before parsing","Validate against the same regex the library uses before calling"],"tags":["version-parsing","validation","java"],"backgroundTag":"invalid-identifier-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"}