You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/07/24 15:26:28 UTC

[PR] Fix #12531: filter NO_REPOSITORY sentinel from mapped exceptions in ArtifactResolverResult [maven]

gnodet opened a new pull request, #12533:
URL: https://github.com/apache/maven/pull/12533

   ## Summary
   
   Fixes #12531 — Plugins that resolve dependencies (cyclonedx-maven-plugin, camel-spring-boot-generator) throw `IllegalArgumentException: Unsupported repository type: class org.eclipse.aether.resolution.ArtifactResult$NoRepository` when building the dependency tree under Maven 4.
   
   ### Root cause
   
   `ArtifactResult.NO_REPOSITORY` is a sentinel used in the resolver's mapped exceptions for errors with no associated repository. When `DefaultArtifactResolver.toResult()` converts these to the Maven API, the `NO_REPOSITORY` key was mapped to a `null` key in the `Map<Repository, List<Exception>>` exposed through `ResultItem.getExceptions()`. This null key could cause `NullPointerException` in downstream code iterating over the exceptions map.
   
   ### Changes
   
   - **Filter out `NO_REPOSITORY` entries** from the mapped exceptions map in `toResult()`, ensuring no null keys leak into the public API
   - **Preserve all exceptions** (including `NO_REPOSITORY` ones) in a separate flat list (`allExceptions`) so that `isMissing()` still correctly considers all exceptions
   - **Use `merge()`** when building the exceptions map for robustness against duplicate keys
   - **Add 3 unit tests** covering:
     - `NO_REPOSITORY` entries don't produce null keys in the exceptions map
     - `isMissing()` correctly considers `NO_REPOSITORY` exceptions (including non-`ArtifactNotFoundException` types)
     - Resolved artifacts with `NO_REPOSITORY` exceptions are handled properly
   
   This builds on commit a2aed724 which added `NO_REPOSITORY` handling to `AbstractSession.getRepository()`.
   
   ## Test plan
   
   - [x] New unit tests: `DefaultArtifactResolverTest` (3 tests)
   - [x] Module tests: `mvn verify` in `impl/maven-impl` (515 tests pass)
   - [x] Full reactor build: `mvn clean install -DskipTests` passes
   - [ ] Verify with affected plugins (cyclonedx-maven-plugin, camel-spring-boot-generator) against this build
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix #12531: filter NO_REPOSITORY sentinel from mapped exceptions in ArtifactResolverResult [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #12533:
URL: https://github.com/apache/maven/pull/12533#issuecomment-5074521146

   Addressed the additional observation in 34466948c3: wrapped `mappedExceptions` with `Map.copyOf()` for consistency with the `List.copyOf(allExceptions)` wrapping. Updated test assertions to use `keySet().stream().noneMatch()` instead of `containsKey(null)` since immutable maps throw NPE on null key lookups.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix #12531: filter NO_REPOSITORY sentinel from mapped exceptions in ArtifactResolverResult [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #12533:
URL: https://github.com/apache/maven/pull/12533#issuecomment-5074447905

   Thanks for the review! Both observations addressed in 27ee62b:
   
   1. **`List.copyOf(allExceptions)`** — wrapped for defensive immutability, consistent with record semantics.
   2. **Vacuous truth guard on `isMissing()`** — added `!allExceptions.isEmpty()` check so an empty exception list doesn't falsely report the artifact as missing. Added a dedicated test for this edge case.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix #12531: filter NO_REPOSITORY sentinel from mapped exceptions in ArtifactResolverResult [maven]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12533:
URL: https://github.com/apache/maven/pull/12533#issuecomment-5100506180

   @gnodet Please assign appropriate label to PR according to the type of change.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix #12531: filter NO_REPOSITORY sentinel from mapped exceptions in ArtifactResolverResult [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #12533:
URL: https://github.com/apache/maven/pull/12533


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org