Introduce validation control - #12548
Conversation
Enables validation level choice in Maven Resolver validator. This change should go to every Maven version having `MavenValidator` (3.10, 4.0 and 4.1). Related: apache/maven-resolver#2007 Backport of: 5703b7d
gnodet
left a comment
There was a problem hiding this comment.
Clean backport of commit 5703b7d (PR #12520) to maven-4.0.x. The design and implementation are sound, but there is a case-sensitivity issue in the documented config values.
Case-sensitive enum mismatch (medium): The Javadoc documents lowercase values (default, mild, off) and @Config(defaultValue = "default") also uses lowercase, but ConfigUtils.getEnum in resolver 2.0.21 uses Enum.valueOf which is case-sensitive. Users following the docs with -Dmaven.resolver.validation=default will get IllegalArgumentException because the enum constant is DEFAULT. The runtime default (when the property is unset) works correctly since it uses ValidationLevel.DEFAULT directly.
Consider either updating the Javadoc to document uppercase values, or handling case conversion before the enum lookup. This same issue exists in the original merge on master (PR #12520) and in the 3.10.x backport (PR #12549).
Minor: No unit tests exist for MavenValidator or MavenValidatorFactory — this is a pre-existing gap, not introduced by this PR.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
|
|
||
| /** | ||
| * Resolver validation control. | ||
| * Can be <code>default</code> (full validation), <code>mild</code> (only uninterpolated placeholders) or |
There was a problem hiding this comment.
The Javadoc documents lowercase values (default, mild, off) and @Config(defaultValue = "default") uses lowercase too. However, ConfigUtils.getEnum in resolver 2.0.21 calls Enum.valueOf(enumClass, (String) value) which is case-sensitive. A user setting -Dmaven.resolver.validation=default (following this doc) will hit IllegalArgumentException because the enum constant is DEFAULT.
Consider either:
- Updating the Javadoc/defaultValue to use uppercase (
DEFAULT,MILD,OFF), or - Adding a
toUpperCase(Locale.ROOT)call before the enum lookup inMavenValidatorFactory.
|
Damn, I mixed helper methods assuming it is fixing the case 😞 Will have another round to fix Javadoc (3.10, 4.0, 4.1) |
Enables validation level choice in Maven Resolver validator.
This change should go to every Maven version having
MavenValidator(3.10, 4.0 and 4.1).Related: apache/maven-resolver#2007
Backport of: 5703b7d