gnodet-bot commented on PR #14012:
URL: https://github.com/apache/maven/pull/14012#issuecomment-6950054944
Hi @Sahil-Jaiswal-189, thanks for the contribution! CI is failing due to a
regression introduced by the new error propagation logic. Here's the full
diagnosis.
## CI failures summary
| Failure | Root cause |
|---|---|
| `integration-tests` (all platforms/JDKs) |
`MavenITmng2199ParentVersionRangeTest.testInvalidLocalParentVersionRange` —
regression caused by this PR |
| `full-build (macos-latest, 25)` | `RequestTraceTest` / `TestApiStandalone`
— infra-only network unavailability (`UnknownHostException:
repo.maven.apache.org`), not related to this PR |
## Root cause of the IT regression
The failing IT test (`testInvalidLocalParentVersionRange`) builds a child
POM that declares `<version>[2,3]</version>` as parent version range. No
matching parent exists locally or remotely — the build must fail with a
**"Non-resolvable parent POM"** error message that includes the coordinates.
The test expects this in the Maven log:
```
Non-resolvable parent POM org.apache.maven.its.mng2199:local-parent:[2,3] ...
```
The break is caused by an interaction between the new
`checkVersionRangeResult()` method and
`DefaultModelBuilder.containsCoordinates()`.
### What changed
Your new `checkVersionRangeResult()` throws a
`VersionRangeResolverException` with this message:
```
Unable to resolve version range for
org.apache.maven.its.mng2199:local-parent:[2,3]: <original cause>
```
That exception **includes the coordinates** in its message. It propagates
through `DefaultModelResolver.resolveModel()`, which catches it and re-wraps it
as a `ModelResolverException`. That exception then reaches
`DefaultModelBuilder`, which calls `containsCoordinates()` before deciding
whether to append the GAV to the "Non-resolvable parent POM" buffer:
```java
// DefaultModelBuilder.java ~line 1502
buffer.append("Non-resolvable parent POM");
if (!containsCoordinates(e.getMessage(), groupId, artifactId, version)) {
buffer.append(' ').append(ModelProblemUtils.toId(groupId, artifactId,
version));
}
```
Because the exception message **already contains**
`org.apache.maven.its.mng2199`, `local-parent`, and `[2,3]`,
`containsCoordinates()` returns `true` — and the coordinates are **not**
appended. The final message becomes:
```
Non-resolvable parent POM: Unable to resolve version range for ...
```
That doesn't match the expected pattern `Non-resolvable parent POM
org.apache.maven.its.mng2199:local-parent:\[2,3\]`, so the IT assertion fails.
### How to fix
The simplest fix is to **not include the artifact coordinates in the
`VersionRangeResolverException` message** thrown by
`checkVersionRangeResult()`. Use only the original exception's message for the
detail part, and let `DefaultModelBuilder`'s existing logic add the
coordinates. Change the message in `checkVersionRangeResult()` from:
```java
// Before (includes coordinates → triggers containsCoordinates() early exit
in DefaultModelBuilder)
VersionRangeResolverException failure = new VersionRangeResolverException(
"Unable to resolve version range for " + artifact + ": " + details,
exceptions.get(0));
```
to something that does NOT embed the coordinates:
```java
// After (details only → DefaultModelBuilder appends coordinates normally)
VersionRangeResolverException failure = new VersionRangeResolverException(
"Unable to resolve version range: " + details, exceptions.get(0));
```
Alternatively, adjust `DefaultModelBuilder` to always append the coordinates
regardless of `containsCoordinates()` when the failing exception is a
`VersionRangeResolverException`, but that is a larger change with more risk.
You will also need to update `MetadataVersionTokenValidationTest` to match
the revised message:
```java
assertTrue(
error.getMessage().contains("Unable to resolve version range:
Rejecting metadata..."),
error.getMessage());
```
_This diagnosis was generated by an AI agent, Hermès on behalf of @gnodet._
<!-- reviewer: gnodet-bot -->
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]