GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix #1269: Report a clear message when resolving an artifact with no … by arturobernalg · Pull Request #2209 · apache/maven-resolver

Conversation

@arturobernalg

@arturobernalg arturobernalg commented Oct 19, 2026

Copy link
Copy Markdown
Member

What and why

DefaultArtifactResolver accepts a VersionResult whose version is null or blank, which happens whenever the request's Artifact has no version at all (#1269 / MRESOLVER-597). It keeps going, and the failure only surfaces much later as an opaque IllegalArgumentException thrown by DefaultLocalPathComposer about an invalid relative path, for instance com/example/no-such-artifact//no-such-artifact-.jar, with no mention of the real cause.

I reproduced this against the current maven-resolver-impl code, both as a unit test and as a standalone program using maven-resolver-supplier-mvn3: resolving com.example:no-such-artifact:jar with no version throws that unrelated path exception.

The issue suggested either documenting the exception or failing fast when the request is built. Failing fast at construction time is not possible in general, because the input version can be a symbolic one (RELEASE, LATEST, a range) that only the version resolver can turn into a concrete version, so the earliest point where an empty result is known is right after versionResolver.resolveVersion returns.

How

DefaultArtifactResolver#resolve now rejects a null or blank resolved version immediately after it is applied to the artifact, with an ArtifactNotFoundException that names the artifact and says its version is missing or blank, instead of letting execution reach the local repository path composer.

Tests

DefaultArtifactResolverTest#testResolveArtifactWithBlankVersionFailsWithClearMessage fails without the change (the stub local repository manager used in this test class does not reproduce the production IllegalArgumentException, but the assertion on the clear message fails, confirming no such message was produced before). With the change, this test and the rest of maven-resolver-impl pass (589 tests), and checkstyle:check is clean.


To make clear that you license your contribution under
the Apache License Version 2.0, January 2004 (http://www.apache.org/licenses/LICENSE-2.0)
check one of the following:

  • I hereby declare this contribution to be licensed under the Apache License Version 2.0, January 2004
  • I hereby declare that I have filed an Apache Individual Contributor License Agreement.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gnodet-bot
gnodet-bot reviewed Oct 19, 2026
View reviewed changes

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is correct and properly validated. One dead branch in the guard condition worth cleaning up.

✅ Pre-fix validation: test confirmed failing before fix (no ArtifactNotFoundException with "missing or blank" in the message), passing after.


Backport note: This is a user-visible bug (resolveArtifact() throwing an opaque IllegalArgumentException instead of a clear ArtifactNotFoundException). The maven-resolver-1.9.x maintenance branch exists — users on that line can hit this same issue. A backport PR would be worth opening.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@arturobernalg
arturobernalg force-pushed the fix/mresolver-597-empty-version-fail-fast branch from a3d7bb9 to c9c0ebf Compare October 19, 2026 11:49
@arturobernalg

arturobernalg commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

Pushed the dead-branch fix (see inline reply/thread above). On the backport note: agreed this affects maven-resolver-1.9.x too, but I'll hold off opening that PR until after this one lands on master, to keep them separate and avoid rebasing a backport against a moving target.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gnodet-bot
gnodet-bot reviewed Oct 19, 2026
View reviewed changes

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — the isEmpty() → trim().isEmpty() issue has been addressed.

✅ Pre-fix validation: The two new tests correctly exercise the guard: the stub version resolver echoes the artifact's own version, so blank and whitespace-only inputs reach the new check and produce the expected ArtifactNotFoundException with a clear message.

One minor nit remains (see inline).


This review was generated by an AI agent, Hermès on behalf of @gnodet.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

gnodet-bot
gnodet-bot reviewed Oct 19, 2026
View reviewed changes

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — the isEmpty() → trim().isEmpty() issue has been addressed.

✅ Pre-fix validation: The two new tests correctly exercise the guard: the stub version resolver echoes the artifact's own version, so blank and whitespace-only inputs reach the new check and produce the expected ArtifactNotFoundException with a clear message.

One minor nit remains (see inline).


This review was generated by an AI agent, Hermès on behalf of @gnodet.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@arturobernalg
Fix apache#1269: Report a clear message when resolving an artifact wi…
19523fb
…th no version

DefaultArtifactResolver accepted a VersionResult whose version was null or
blank (as happens for an ArtifactRequest built from an Artifact with no
version at all) and kept going, so the failure only surfaced later, as an
opaque IllegalArgumentException from DefaultLocalPathComposer about an
invalid relative path.

Reject it right after the version is resolved, with an
ArtifactNotFoundException that names the artifact and says its version is
missing or blank. Also treat a whitespace-only version as blank, since it
is just as unusable and would otherwise reach the path composer unchecked.

Fixes MRESOLVER-597
@arturobernalg
arturobernalg force-pushed the fix/mresolver-597-empty-version-fail-fast branch from c9c0ebf to 19523fb Compare October 19, 2026 12:06
gnodet-bot
gnodet-bot approved these changes Oct 19, 2026
View reviewed changes

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review after the latest commit (19523fb) — the previous finding has been addressed.

✅ Addressed: artifact.getVersion() == null dead null check has been removed. The guard is now artifact.getVersion().trim().isEmpty(), which is both correct and NPE-safe (AbstractArtifact.setVersion() normalizes null to empty string).

The fix is clean and ready to merge:

  • Guard condition correctly handles null/blank versions
  • ArtifactResult.NO_REPOSITORY is the right sentinel for repository-less exceptions
  • Error message includes full artifact coordinates for actionability
  • Test coverage is solid (assertNull(result.getArtifact()) correctly verifies no artifact is set)

💡 Suggestion: Consider backporting to maven-resolver-1.9.x — this is a user-visible bug that produces a confusing NPE/AIOOBE instead of a clear error message.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cstamas cstamas added this to the 2.0.25 milestone Oct 20, 2026
@cstamas cstamas added the enhancement New feature or request label Oct 20, 2026
cstamas
cstamas approved these changes Oct 20, 2026
View reviewed changes
@cstamas
cstamas merged commit e9cd7f3 into apache:master Oct 20, 2026
20 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot assigned cstamas Oct 20, 2026
@arturobernalg arturobernalg mentioned this pull request Oct 22, 2026
[maven-resolver-1.9.x] Fix #1269: Report a clear message when resolving an artifact with no version #2221
Open
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cstamas cstamas cstamas approved these changes
+1 more reviewer
@gnodet-bot gnodet-bot gnodet-bot approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@cstamas cstamas

Labels

enhancement New feature or request

Projects

None yet

Milestone

2.0.25

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@arturobernalg @cstamas @gnodet-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.