quarkusio/quarkus · error · BootstrapMavenException

Failed to resolve version range for ${artifact}

Error message

Failed to resolve version range for ${artifact}

What it means

resolveVersionRange(Artifact) uses Aether's resolveVersionRange to enumerate versions matching the artifact's version range. A VersionRangeResolutionException (no repository can answer the range, invalid range, or repo errors) is wrapped as 'Failed to resolve version range for <gav>'.

Source

Thrown at independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/MavenArtifactResolver.java:210

        try {
            return repoSystem.readArtifactDescriptor(repoSession,
                    new ArtifactDescriptorRequest()
                            .setArtifact(artifact)
                            .setRepositories(
                                    aggregatedRepos));
        } catch (ArtifactDescriptorException e) {
            throw new BootstrapMavenException("Failed to read descriptor of " + artifact, e);
        }
    }

    public VersionRangeResult resolveVersionRange(Artifact artifact) throws BootstrapMavenException {
        try {
            return repoSystem.resolveVersionRange(repoSession,
                    new VersionRangeRequest()
                            .setArtifact(artifact)
                            .setRepositories(remoteRepos));
        } catch (VersionRangeResolutionException ex) {
            throw new BootstrapMavenException("Failed to resolve version range for " + artifact, ex);
        }
    }

    public String getLatestVersionFromRange(Artifact artifact, String range) throws BootstrapMavenException {
        return getLatest(resolveVersionRange(new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(),
                artifact.getClassifier(), artifact.getExtension(), range)));
    }

    private String getLatest(final VersionRangeResult rangeResult) {
        final List<Version> versions = rangeResult.getVersions();
        if (versions.isEmpty()) {
            return null;
        }
        Version next = versions.get(0);
        for (int i = 1; i < versions.size(); ++i) {
            final Version candidate = versions.get(i);
            if (candidate.compareTo(next) > 0) {
                next = candidate;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Validate the version range syntax (e.g. '[1.0,2.0)') before calling
  2. Ensure the artifact is published to one of the configured repositories so maven-metadata.xml exists
  3. Inspect the cause VersionRangeResolutionException for the specific range problem
  4. Check network/proxy availability to the remote repository

Example fix

// before
new DefaultArtifact("g","a","jar","1.0+");
// after
new DefaultArtifact("g","a",null,"jar","[1.0,)");
Defensive patterns

Strategy: validation

Validate before calling

String range = "[1.0,)";
if (!range.matches("[\\[\\(].*[\\]\\)]"))
    throw new IllegalArgumentException("Invalid version range: " + range);

Type guard

boolean validRange(String v) {
    return v != null && (v.startsWith("[") || v.startsWith("("))
        && (v.endsWith("]") || v.endsWith(")"));
}

Try / catch

try {
    VersionRangeResult r = resolver.resolveVersionRange(artifact);
} catch (BootstrapMavenException e) {
    if (e.getCause() instanceof VersionRangeResolutionException vre)
        log.error("Range " + artifact.getVersion() + " failed: " + vre.getMessage());
}

Prevention

When it happens

Trigger: Calling resolveVersionRange or getLatestVersionFromRange with a malformed version range (e.g. bad '[1.0,' syntax), or when none of the configured remote repositories can provide version metadata (maven-metadata.xml) for the artifact.

Common situations: Querying the 'latest available version' of an artifact that only exists locally (remote metadata absent); invalid range syntax like '1.+' with unusual versions; repository metadata corrupted; offline mode with no local metadata.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/4831a786ab5a7117. Report an issue: GitHub.