Skip to content

Accept documented lowercase values for maven.resolver.validation - #13407

Merged
gnodet merged 1 commit into
apache:masterfrom
cmunier:resolver-validation-case-insensitive
Oct 13, 2026
Merged

gnodet merged 1 commit into
apache:masterfrom
cmunier:resolver-validation-case-insensitive

Conversation

@cmunier

@cmunier cmunier commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

maven.resolver.validation is documented with the values default, mild and off (Javadoc of Constants.MAVEN_RESOLVER_VALIDATION, @Config(defaultValue = "default"), and the Maven 3.10.0 release notes). However, MavenValidatorFactory parses the value with ConfigUtils.getEnum(), which uses Enum.valueOf() and is case-sensitive. Following the documentation therefore fails the build:

$ mvn -Dmaven.resolver.validation=mild verify
[ERROR] Internal error: java.lang.IllegalArgumentException: No enum constant org.apache.maven.internal.aether.MavenValidatorFactory.ValidationLevel.mild -> [Help 1]

Only MILD and OFF work. 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:

Invalid value 'foo' for maven.resolver.validation, supported values are: default, mild, off

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 a system-scoped dependency whose classifier contains a /: without the property the build fails as expected, and it passes with mild, MILD and Off.

Backport: the same code is in maven-4.0.x (impl/maven-impl) and maven-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 for maven-3.10.x if you like.

AI disclosure: drafted with Claude Code (Anthropic Claude Opus 5.5, interactive mode). I have reviewed and tested the change myself.


@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@slawekjaranowski slawekjaranowski added the bug Something isn't working label Oct 11, 2026
@cmunier
cmunier force-pushed the resolver-validation-case-insensitive branch from 0486d6c to 3fe695a Compare October 12, 2026 18:59

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)
@cmunier
cmunier force-pushed the resolver-validation-case-insensitive branch from 3fe695a to f76a3c5 Compare October 13, 2026 06:52
@cmunier
cmunier requested a review from gnodet-bot October 13, 2026 06:53

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@gnodet
gnodet merged commit 0b31e29 into apache:master Oct 13, 2026
22 checks passed
@github-actions github-actions Bot added this to the 4.1.0 milestone Oct 13, 2026
gnodet added a commit that referenced this pull request Oct 14, 2026
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)
gnodet added a commit that referenced this pull request Oct 14, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants