{"record":{"id":"4226f54b2e63203c","repo":"apache/maven","slug":"unable-to-parse-version","errorCode":null,"errorMessage":"Unable to parse version: ","messagePattern":"Unable to parse version: ","errorType":"validation","errorClass":"VersionParserException","httpStatus":null,"severity":"error","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultModelVersionParser.java","lineNumber":90,"sourceCode":"        requireNonNull(constraint, \"constraint\");\n        return new DefaultVersionConstraint(versionScheme, constraint);\n    }\n\n    static class DefaultVersion implements Version {\n        private final VersionScheme versionScheme;\n        private final org.eclipse.aether.version.Version delegate;\n\n        DefaultVersion(VersionScheme versionScheme, org.eclipse.aether.version.Version delegate) {\n            this.versionScheme = versionScheme;\n            this.delegate = delegate;\n        }\n\n        DefaultVersion(VersionScheme versionScheme, String delegateValue) {\n            this.versionScheme = versionScheme;\n            try {\n                this.delegate = versionScheme.parseVersion(delegateValue);\n            } catch (InvalidVersionSpecificationException e) {\n                throw new VersionParserException(\"Unable to parse version: \" + delegateValue, e);\n            }\n        }\n\n        @Override\n        public int compareTo(Version o) {\n            if (o instanceof DefaultVersion defaultVersion) {\n                return delegate.compareTo(defaultVersion.delegate);\n            } else {\n                return compareTo(new DefaultVersion(versionScheme, o.toString()));\n            }\n        }\n\n        @Override\n        public boolean equals(Object o) {\n            if (this == o) {\n                return true;\n            }\n            if (o == null || getClass() != o.getClass()) {","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultModelVersionParser.java#L72-L108","documentation":"DefaultModelVersionParser's DefaultVersion wraps the resolver VersionScheme; parsing a version string that the scheme rejects throws VersionParserException('Unable to parse version: <input>'). The generic parse is used when a raw string (e.g. from a POM property or plugin parameter) must become a Version object, and the underlying scheme (typically GenericVersionScheme) rejects malformed input such as empty strings.","triggerScenarios":"session.getService(VersionParser.class).parseVersion(''), parseVersion('${some.unset.property}'), or a version string with characters the version scheme cannot tokenize; also compareTo on a foreign Version implementation that re-parses its toString().","commonSituations":"POM properties for versions left uninterpolated; user input or CLI args (-Dversion=...) passed to version comparisons; empty default version strings in code; version strings with stray whitespace.","solutions":["Trim and reject empty/uninterpolated ('${...}') strings before parsing","Catch VersionParserException and report which string failed with the POM/location context","Where possible use versionScheme.parseVersion indirectly through Model API which surfaces better diagnostics"],"exampleFix":"// before\nVersion v = session.getService(VersionParser.class).parseVersion(props.getProperty('project.version'));\n\n// after\nString raw = props.getProperty('project.version');\nif (raw == null || raw.isBlank() || raw.contains('${')) {\n    throw new IllegalArgumentException('project.version not interpolated: ' + raw);\n}\nVersion v = session.getService(VersionParser.class).parseVersion(raw.trim());","handlingStrategy":"try-catch","validationCode":"if (version == null || version.isBlank() || version.contains('${')) {\n    throw new IllegalArgumentException('Version string is blank or uninterpolated: ' + version);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Version v = parser.parseVersion(raw);\n} catch (VersionParserException e) {\n    throw new IllegalArgumentException('Bad version \"' + raw + '\" in ' + source, e);\n}","preventionTips":["Trim version strings and reject blanks/uninterpolated properties","Carry the POM location/context in wrapped errors for diagnosability","Prefer comparing already-parsed Version objects over re-parsing strings"],"tags":["maven","version-parsing","pom","validation"],"backgroundTag":"invalid-version-string","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}