Skip to content

Documentation says that version ranges should not resolve to SNAPSHOT, but SNAPSHOT repos are still queried #906

Closed

Description

@ctubbsii

Affected version

3.6.0

Bug description

The documentation for maven-enforcer-plugin has a link to Version Ranges that says:

Resolution of dependency ranges should not resolve to a snapshot (development version) unless it is included as an explicit boundary.

However, in my observations, ALL configured repositories are queried for available versions, without regard to whether they are configured for snapshots or releases. It is possible that the quoted portion is still correct, and that SNAPSHOT versions are filtered out after retrieval. However, the expected behavior is that if these versions are to be excluded, then the repositories configured for snapshots only, should never be queried at all when resolving version ranges. This may be a bug elsewhere in Maven, but the linked documentation from the maven-enforcer-plugin should, at the very least, document this behavior, if it is expected.

Note: this behavior is particularly problematic, because repository.apache.org is configured as a snapshot repository by default in the Apache parent POM, and INFRA blocks when you access repository.apache.org with too many 404s. This means that too many version ranges anywhere in your dependency tree will get you banned, even if you never depended on any SNAPSHOT versions.

Activity

  1. added
    bug
    on Jul 2, 2025
  2. cstamas commented on Jul 2, 2025

    @cstamas
    Member

    For latter: yes, ASF will block you if you produce excessive amount of 404s, but asking for metadata will not cause 404, unless you ask for GA that is for sure not on ASF repo.

    For this, ideally one can use RRF (remote repository filtering):
    https://maveniverse.eu/docs/heimdall/

    And given ASF repo publishes prefix files, just by adding this extension will prevent your Maven to ask for GAs not present on ASF repo.

  3. ctubbsii commented on Jul 3, 2025

    @ctubbsii
    MemberAuthor

    For latter: yes, ASF will block you if you produce excessive amount of 404s, but asking for metadata will not cause 404, unless you ask for GA that is for sure not on ASF repo.

    The metadata that is being asked for that does cause 404s is the maven-metadata.xml files that are per artifactId, and are used to resolve version ranges.

    For this, ideally one can use RRF (remote repository filtering): https://maveniverse.eu/docs/heimdall/

    And given ASF repo publishes prefix files, just by adding this extension will prevent your Maven to ask for GAs not present on ASF repo.

    Presumably, using a new enough version of Maven and/or using this plugin will help prevent some 404s when looking up specific artifact information, but I don't know if that will help in the specific code path where version ranges are resolved, since that code path already has the groupId and artifactId, and is just looking at the metadata to determine what versions are available on the server. Even if it does help in that specific version range resolution code path, it's very hard to get everybody on the newer version of Maven that checks for these prefix files.

    In any case, this issue is mainly about the incomplete documentation of Maven's behavior of checking these snapshot repos for versions even when it can't resolve to a snapshot version. This plugin's documentation links to that confluence page, so I placed the issue here. I'm not actually sure who is responsible for maintaining that confluence page's contents.

    I filed a separate bug about the behavior itself, since it probably is a bug (apache/maven#2558). If the version range cannot resolve to a snapshot version, according to this documentation, then snapshot-only repos should never be queried at all, rather than their results filtered out later. Filtering at the artifact level, based on the results of the metadata, or based on the prefixes, both seem far too late.

  4. slawekjaranowski commented on Jul 6, 2025

    @slawekjaranowski
    Member

    Can we do something more in enforcer project with it?

  5. ctubbsii commented on Aug 29, 2025

    @ctubbsii
    MemberAuthor

    Can we do something more in enforcer project with it?

    It seems like the enforcer plugin should not link to the old confluence page at https://github.com/apache/maven-enforcer/blob/master/maven-enforcer-plugin/src/site/site.xml#L41-L43

  6. added a commit that references this issue on Aug 29, 2025
    13794b0
  7. added a commit that references this issue on Sep 19, 2025
    03ed82d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions