{"record":{"id":"7a1d0d57fa0f9111","repo":"apache/maven","slug":"could-not-parse-current-maven-version","errorCode":null,"errorMessage":"Could not parse current Maven version: {}","messagePattern":"Could not parse current Maven version: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java","lineNumber":112,"sourceCode":"        }\n\n        VersionConstraint constraint;\n        try {\n            constraint = versionScheme.parseVersionConstraint(versionRange);\n        } catch (InvalidVersionSpecificationException e) {\n            throw new IllegalArgumentException(e.getMessage(), e);\n        }\n\n        Version current;\n        try {\n            String mavenVersion = getMavenVersion();\n            if (mavenVersion.isEmpty()) {\n                throw new IllegalArgumentException(\"Could not determine current Maven version\");\n            }\n\n            current = versionScheme.parseVersion(mavenVersion);\n        } catch (InvalidVersionSpecificationException e) {\n            throw new IllegalStateException(\"Could not parse current Maven version: \" + e.getMessage(), e);\n        }\n\n        if (constraint.getRange() == null) {\n            return constraint.getVersion().compareTo(current) <= 0;\n        }\n        return constraint.containsVersion(current);\n    }\n}\n","sourceCodeStart":94,"sourceCodeEnd":121,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java#L94-L121","documentation":"After reading the version string, DefaultRuntimeInformation parses it with the injected version scheme. If the string does not form a valid Maven version (arbitrary text or a malformed value), the parse fails and the method throws IllegalStateException wrapping InvalidVersionSpecificationException, with the parse error included in the message.","triggerScenarios":"maven-version.properties containing a hand-edited value the version scheme cannot parse, or test code stubbing the runtime version with a non-version string.","commonSituations":"Hand-built or patched Maven distributions; filtering pipelines that mangle the version placeholder; unit tests stubbing getMavenVersion with values like CURRENT or ver-one.","solutions":["Read the offending version from the exception message and restore a standard value such as 3.9.6 or 3.9.6-SNAPSHOT","Rebuild or re-filter maven-version.properties from a clean build","In tests, stub getMavenVersion() with a parseable version"],"exampleFix":"# before (maven-version.properties)\nversion=ver-$BUILD\n\n# after\nversion=3.9.6","handlingStrategy":"try-catch","validationCode":"String v = rtInfo.getMavenVersion();\nif (!v.matches(\"[0-9]+(\\\\.[0-9]+)*(-[A-Za-z0-9.]+)?\")) {\n    throw new IllegalStateException(\"unparseable runtime version: \" + v);\n}","typeGuard":null,"tryCatchPattern":"try {\n    rtInfo.isMavenVersion(range);\n} catch (IllegalStateException e) {\n    // message includes the offending version string: fix the distribution metadata\n    throw new IllegalStateException(\"bad maven-version.properties\", e);\n}","preventionTips":["Keep the version property in sync with a real Maven release","Validate patched distributions with mvn -version before use"],"tags":["maven","version","parse","metadata"],"backgroundTag":"version-parse-failure","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}