apache/maven · error · VersionParserException
Unable to parse version range:
Error message
Unable to parse version range:
What it means
DefaultModelVersionParser.DefaultVersionRange parses range expressions like [1.0,2.0), (,1.5], [1.1] through the resolver VersionScheme. Malformed range syntax throws VersionParserException('Unable to parse version range: <input>'). The input must be a range specification, not a plain version — a bare '1.0' is invalid here (use parseVersion) and unbalanced or misordered brackets/commas are rejected.
Source
Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultModelVersionParser.java:141
return delegate.toString();
}
}
static class DefaultVersionRange implements VersionRange {
private final VersionScheme versionScheme;
private final org.eclipse.aether.version.VersionRange delegate;
DefaultVersionRange(VersionScheme versionScheme, org.eclipse.aether.version.VersionRange delegate) {
this.versionScheme = versionScheme;
this.delegate = delegate;
}
DefaultVersionRange(VersionScheme versionScheme, String delegateValue) {
this.versionScheme = versionScheme;
try {
this.delegate = versionScheme.parseVersionRange(delegateValue);
} catch (InvalidVersionSpecificationException e) {
throw new VersionParserException("Unable to parse version range: " + delegateValue, e);
}
}
@Override
public boolean contains(Version version) {
if (version instanceof DefaultVersion defaultVersion) {
return delegate.containsVersion(defaultVersion.delegate);
} else {
return contains(new DefaultVersion(versionScheme, version.toString()));
}
}
@Override
public Boundary getUpperBoundary() {
org.eclipse.aether.version.VersionRange.Bound bound = delegate.getUpperBound();
if (bound == null) {
return null;
}View on GitHub (pinned to e4093d4e12)
Solutions
- Use proper range syntax with balanced brackets and a comma between bounds, e.g. '[1.0,2.0)' or '[1.0]'
- If the value is a single version, call parseVersion instead of parseVersionRange
- Validate user-supplied ranges with a regex like ^[\[(].*[\])] before passing them in
Example fix
<!-- before --> <version>[1.0,2.0</version> <!-- after --> <version>[1.0,2.0)</version>
Defensive patterns
Strategy: try-catch
Validate before calling
private static final Pattern RANGE = Pattern.compile('^[\\[(].*,.*[\\])]$');
if (!RANGE.matcher(range.trim()).matches()) {
throw new IllegalArgumentException('Not a valid version range: ' + range);
} Try / catch
try {
VersionRange r = parser.parseVersionRange(range);
} catch (VersionParserException e) {
throw new IllegalArgumentException('Bad range "' + range + '"; expected e.g. [1.0,2.0)', e);
} Prevention
- Require balanced brackets and a comma in every range expression
- Use parseVersion for single versions, parseVersionRange only for ranges
- Validate ranges at configuration-load time, not deep in dependency resolution
When it happens
Trigger: session.getService(VersionParser.class).parseVersionRange('1.0') (plain version instead of range), '[1.0,2.0' (missing bracket), '[2.0,1.0)' (lower bound above upper), or an uninterpolated '${range}' property.
Common situations: Version ranges in dependencyManagement or plugin configuration with typos; copy-pasting a range missing the closing parenthesis; forgetting Maven requires hard ([...]) or soft ((...)) bounds on at least one side; properties for ranges left unexpanded.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Invalid JDK version in profile '{}': {}
- Repository identifier missing
- URL missing for repository " + id
- Repository identifier missing
- URL missing for repository {}
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/a795a736bcecc4e6.
Report an issue: GitHub.