{"record":{"id":"69b20d71fca9c24f","repo":"apache/maven","slug":"couldn-t-find-a-version-in-versions-to-mat","errorCode":null,"errorMessage":"Couldn't find a version in \" + versions + \" to match range \" + versionRange","messagePattern":"Couldn't find a version in \" \\+ versions \\+ \" to match range \" \\+ versionRange","errorType":"exception","errorClass":"OverConstrainedVersionException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java","lineNumber":480,"sourceCode":"                                            artifact.setAvailableVersions(versions);\n                                        }\n\n                                        Collections.sort(versions);\n\n                                        VersionRange versionRange = artifact.getVersionRange();\n\n                                        version = versionRange.matchVersion(versions);\n\n                                        if (version == null) {\n                                            if (versions.isEmpty()) {\n                                                throw new OverConstrainedVersionException(\n                                                        \"No versions are present in the repository for the artifact\"\n                                                                + \" with a range \" + versionRange,\n                                                        artifact,\n                                                        childRemoteRepositories);\n                                            }\n\n                                            throw new OverConstrainedVersionException(\n                                                    \"Couldn't find a version in \" + versions + \" to match range \"\n                                                            + versionRange,\n                                                    artifact,\n                                                    childRemoteRepositories);\n                                        }\n                                    } else {\n                                        version = artifact.getSelectedVersion();\n                                    }\n\n                                    artifact.selectVersion(version.toString());\n                                    fireEvent(ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, child);\n                                }\n\n                                rGroup = source.retrieve(metadataRequest);\n\n                                if (rGroup == null) {\n                                    break;\n                                }","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/DefaultLegacyArtifactCollector.java#L462-L498","documentation":"The non-empty counterpart of the 'no versions present' error in DefaultLegacyArtifactCollector: repository metadata was retrieved and contains versions, but VersionRange.matchVersion(versions) returns null because none of them satisfies the dependency's version range. OverConstrainedVersionException('Couldn't find a version in <versions> to match range <range>') then aborts resolution, listing exactly which versions were available.","triggerScenarios":"A version-range dependency where the intersection of the range and the available-version list is empty — e.g. range (,1.0] with only 1.1+ published, or an exclusive range [1.0,1.1) where metadata lists exactly 1.1.0; also stale local metadata listing older versions than the range's minimum.","commonSituations":"Range lower bound above every published version (waiting for a release that does not exist yet); exclusive bounds accidentally skipping the only existing version; cached maven-metadata.xml in the local repository predating a needed release.","solutions":["Compare the versions listed in the message with the range and either pin one of the listed versions or adjust the bounds","Run mvn -U to refresh stale version metadata before concluding the version is missing","Fix over-tight bounds — commonly an exclusive upper bound like [1.0,1.2) when only 1.2.0 exists","If you need a future version, build and deploy it first, or remove the range until it exists"],"exampleFix":"<!-- before: only 1.2.0 is published -->\n<version>[1.3,)</version>\n\n<!-- after -->\n<version>[1.2,)</version>","handlingStrategy":"validation","validationCode":"VersionRange range = artifact.getVersionRange();\nArtifactVersion match = range.matchVersion(availableVersions);\nif (match == null && !availableVersions.isEmpty()) {\n    throw new IllegalStateException(\"Range \" + range + \" excludes all available versions \"\n            + availableVersions + \" — adjust bounds or pin \" + availableVersions.get(availableVersions.size() - 1));\n}","typeGuard":null,"tryCatchPattern":"catch (OverConstrainedVersionException e) {\n    // message format: \"Couldn't find a version in [...] to match range ...\"\n    // parse or log it to show the user exactly the intersection problem\n    log.error(\"{} — pick a listed version or widen the range\", e.getMessage());\n}","preventionTips":["Double-check exclusive bounds: [1.0,1.1) rejects exactly 1.1.0, a common single-release trap","Refresh metadata with mvn -U before debugging a range mismatch — stale local lists are a frequent cause","Document the intended matching version next to each range in the POM for reviewers"],"tags":["maven","version-range","dependency-resolution","legacy-compat"],"backgroundTag":"no-version-matches-range","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}