Skip to content

[MNG-8129] Handle InvalidPathException for broken relativePath on Windows - #12741

Open
gnodet wants to merge 2 commits into
apache:maven-4.0.xfrom
gnodet:fix/MNG-8129-windows-invalid-path-4.0.x
Open

[MNG-8129] Handle InvalidPathException for broken relativePath on Windows#12741
gnodet wants to merge 2 commits into
apache:maven-4.0.xfrom
gnodet:fix/MNG-8129-windows-invalid-path-4.0.x

Conversation

@gnodet

@gnodet gnodet commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport of #12740 to maven-4.0.x for RC-7.

  • Catch InvalidPathException in BuildPathSource.resolve() and FileModelSource.getRelatedSource() when the <relativePath> value contains characters illegal on certain platforms (e.g. : on Windows)
  • Return null instead of throwing, matching the behavior on platforms where Path.resolve() succeeds but the path doesn't exist
  • Some POMs on Maven Central have nonsensical <relativePath> values like org.apache:apache (e.g. artemis-project-2.33.0.pom) which trigger this on Windows

Fixes https://issues.apache.org/jira/browse/MNG-8129
Related: #12738

🤖 Generated with Claude Code

…dows

Catch InvalidPathException when resolving relative parent paths that
contain characters illegal on certain platforms (e.g. ':' on Windows).
Some POMs on Maven Central have nonsensical <relativePath> values like
"org.apache:apache" which cause Path.resolve() to throw on Windows.
Return null instead, matching the existing behavior on platforms where
the resolve succeeds but the path doesn't exist.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reject <relativePath> values containing characters that are illegal
in filesystem paths (: " < > | ? *) during model validation.
This catches nonsensical values like "org.apache:apache" early, with
a clear error message, complementing the InvalidPathException catch
in the resolution layer.

The check uses errOn31 severity — WARNING for compat (STRICT=3.0)
and ERROR for the new API (STRICT=4.2).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet marked this pull request as ready for review August 13, 2026 02:50

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verdict: APPROVE

Clean backport of #12740 to maven-4.0.x. Catches InvalidPathException when resolving relativePath values with illegal filesystem characters (e.g. org.apache:apache) and adds early model validation to reject such values before resolution.

Key observations:

  • ILLEGAL_RELATIVE_PATH_CHARS correctly excludes \ and / since those are valid path separators in relativePath values.
  • The errOn31 severity is properly calibrated: WARNING in compat module (backward compatibility for Maven 3.x) and ERROR in impl module (strict validation for Maven 4.x).
  • Test POMs are identical between compat/impl modules, with tests correctly targeting validateRaw (compat) and validateFile (impl), matching each module's validation architecture.
  • Consistent with the already-approved PRs #12739 (3.10.x catch), #12740 (master catch + validation), and #12742 (3.10.x validation).

All 22 CI jobs pass across Linux/macOS/Windows and Java 17/21/25.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant