apache/cassandra · error · IllegalArgumentException
Invalid version value
Error message
Invalid version value: ${version}; ${part} not a valid identifier What it means
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.
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
Example fix
// before
new CassandraVersion("4.0.0-beta_1");
// after
new CassandraVersion("4.0.0-beta.1"); Defensive patterns
Strategy: validation
Validate before calling
boolean validIdentifiers(String version) {
int plus = version.indexOf('+');
String tail = plus >= 0 ? version.substring(plus + 1)
: version.contains("-") ? version.substring(version.indexOf('-') + 1) : "";
return java.util.Arrays.stream(tail.split("[.-]"))
.allMatch(p -> p.matches("[0-9A-Za-z]+"));
} Try / catch
try {
CassandraVersion v = new CassandraVersion(version);
} catch (IllegalArgumentException e) {
// e.getMessage() names the offending identifier
throw new ConfigurationException("Unsupported version: " + version, e);
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- A CounterId representation is exactly
- Illegal capacity
- Only single character delimiters supported, was
- Reader index should be non-negative, but was
- Size must be non-negative
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/2ef2c2cefcbf86e1.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/utils/CassandraVersion.java:151
String value = matcher.group(group);
return value == null ? orElse : Integer.parseInt(value);
}
private CassandraVersion getFamilyLowerBound()
{
return patch == 0 && hotfix == NO_HOTFIX && preRelease != null && preRelease.length == 0 && build == null
? this
: new CassandraVersion(major, minor, 0, NO_HOTFIX, ArrayUtils.EMPTY_STRING_ARRAY, null);
}
private static String[] parseIdentifiers(String version, String str)
{
// Drop initial - or +
String[] parts = StringUtils.split(str, ".-");
for (String part : parts)
{
if (!PATTERN_WORDS.matcher(part).matches())
throw new IllegalArgumentException("Invalid version value: " + version + "; " + part + " not a valid identifier");
}
return parts;
}
public List<String> getPreRelease()
{
return preRelease != null ? Arrays.asList(preRelease) : Collections.emptyList();
}
public List<String> getBuild()
{
return build != null ? Arrays.asList(build) : Collections.emptyList();
}
public int compareTo(CassandraVersion other)
{
return compareTo(other, false);
}View on GitHub (pinned to 88fd0f6a0e)