Repository navigation
Accept documented lowercase values for maven.resolver.validation - #13407
Conversation
gnodet
left a comment
There was a problem hiding this comment.
Clean, minimal fix for a documented-vs-actual behavior mismatch.
The maven.resolver.validation property was documented as case-insensitive but parsed with ConfigUtils.getEnum() which is case-sensitive. The fix replaces it with an explicit getString() + valueOf(value.trim().toUpperCase(Locale.ROOT)) approach, correctly handling all documented casings and adding whitespace trimming.
The tests are well-structured: 5 methods covering all three levels (default, mild, off) with case variants, whitespace trimming (mild), and invalid value error messaging. 4/5 tests fail pre-fix as expected.
Should be backported to maven-4.0.x and maven-3.10.x — this is a behavioral mismatch between docs and implementation.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
0486d6c to
3fe695a
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Sound fix for a documented-vs-actual behavior mismatch — the parameterized test refactoring is correct. Three low-severity consistency issues in the new test file.
No milestone is set. This PR targets master (4.1.0-SNAPSHOT); milestone 4.1.0 is appropriate. The author requested backports to maven-4.0.x and maven-3.10.x — a backport-to-4.0.x label should be applied.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
The values of maven.resolver.validation are documented as default, mild and off, but MavenValidatorFactory parsed them with ConfigUtils.getEnum(), which is case-sensitive. Following the documentation, -Dmaven.resolver.validation=mild failed with "Internal error: No enum constant ...ValidationLevel.mild", and only the uppercase values worked. The value is now parsed ignoring case and surrounding whitespace, so both the documented lowercase and the uppercase values work. An unknown value is reported with the property name and the supported values. Added junit-jupiter-params test dependency already used in other maven modules, to use @ParametrizedTest. Co-authored-by: Claude Code (Anthropic Claude Opus 5.5, claude-opus-5-5)
3fe695a to
f76a3c5
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Clean, minimal bug fix that makes maven.resolver.validation accept the documented lowercase values (e.g., mild, off). The implementation correctly uses value.trim().toUpperCase(Locale.ROOT) before valueOf(), and the error message on invalid values is descriptive and includes both the property name and supported values. All three nits from the prior review are fully addressed: license header format, and parameterized tests for defaultLevelIgnoresCase and offLevelIgnoresCase.
Backport to maven-4.0.x would be justified since this is a user-facing bug fix for documented configuration.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Backport of #13407 to `maven-4.0.x`. The property is documented as accepting `default`, `mild`, and `off`, but `MavenValidatorFactory` used `ConfigUtils.getEnum()` / `Enum.valueOf()` which is case-sensitive — so `-Dmaven.resolver.validation=mild` failed with an `IllegalArgumentException`. - Parse the value ignoring case and surrounding whitespace, so both the documented lowercase values and the uppercase equivalents are accepted - Report unknown values with the property name and the list of supported values - Add `MavenValidatorFactoryTest` with parameterized tests covering case variants and the error message (4 of 5 tests fail without the fix)
Backport of #13407 to `maven-3.10.x`. The property is documented as accepting `default`, `mild`, and `off`, but `MavenValidatorFactory` used `ConfigUtils.getEnum()` / `Enum.valueOf()` which is case-sensitive — so `-Dmaven.resolver.validation=mild` failed with an `IllegalArgumentException` (as noted in the 3.10.0 release notes, the escape hatch doesn't work as documented). - Parse the value ignoring case and surrounding whitespace, so both the documented lowercase values and the uppercase equivalents are accepted - Report unknown values with the property name and the list of supported values - Add `MavenValidatorFactoryTest` with parameterized tests covering case variants and the error message (4 of 5 tests fail without the fix) - Adapted from the master/4.0.x fix to the 3.10.x flat layout, using Java 8-compatible `StringJoiner` instead of streams
maven.resolver.validationis documented with the valuesdefault,mildandoff(Javadoc ofConstants.MAVEN_RESOLVER_VALIDATION,@Config(defaultValue = "default"), and the Maven 3.10.0 release notes). However,MavenValidatorFactoryparses the value withConfigUtils.getEnum(), which usesEnum.valueOf()and is case-sensitive. Following the documentation therefore fails the build:Only
MILDandOFFwork. This was noted in the review of #12549, and it affects the escape hatch that the 3.10.0 release notes recommend for builds with non-conformant coordinates.This PR parses the value ignoring case and surrounding whitespace, so both the documented lowercase values and the uppercase values that work today are accepted. An unknown value is now reported with the property name and the supported values:
Tested with the new
MavenValidatorFactoryTest(4 of its 5 tests fail without the change), and end to end with a distribution built from this branch, using a project with asystem-scoped dependency whose classifier contains a/: without the property the build fails as expected, and it passes withmild,MILDandOff.Backport: the same code is in
maven-4.0.x(impl/maven-impl) andmaven-3.10.x(maven-core,org.apache.maven.internal.aether.MavenValidatorFactory). As 3.10.0 is released with this behavior, could this please be backported to both branches? I'm happy to open the backport PR formaven-3.10.xif you like.AI disclosure: drafted with Claude Code (Anthropic Claude Opus 5.5, interactive mode). I have reviewed and tested the change myself.