Skip to content

Improve DefaultModelProcessor error reporting for alternative parsers - #11529

Merged
gnodet merged 2 commits into
maven-4.0.xfrom
improve/model-processor-error-reporting
Dec 9, 2025
Merged

gnodet merged 2 commits into
maven-4.0.xfrom
improve/model-processor-error-reporting

Conversation

@gnodet

@gnodet gnodet commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

When multiple model parsers are registered (e.g., for YAML or TOML POMs) and all parsers fail to parse a POM file, the error message now provides detailed information about each parser's failure.

Changes

  • Changed modelParsers from List<ModelParser> to Map<String, ModelParser> to preserve parser names for better error messages
  • Added buildDetailedErrorMessage() method that generates a comprehensive error report including:
    • The POM file path
    • The number of parsers attempted
    • Each parser's error with line/column information when available
    • The default XML reader's error
  • Updated all call sites to use Map.of() instead of List.of()
  • Added unit tests for the new error reporting functionality

Example Error Output

When a YAML POM file fails to parse:

Unable to parse POM /path/to/pom.yaml
        Tried 2 parsers:
          yaml) YAML parsing failed at line 5, column 10: Invalid YAML syntax
          toml) TOML parsing failed at line 3, column 7
          default) XML reader also failed: XML parsing failed

This improves debugging when using alternative POM formats by showing exactly why each parser failed, rather than just the final XML error.


Pull Request opened by Augment Code with guidance from the PR author

When multiple model parsers are registered (e.g., for YAML or TOML POMs)
and all parsers fail to parse a POM file, the error message now provides
detailed information about each parser's failure.

Changes:
- Changed modelParsers from List to Map<String, ModelParser> to preserve
  parser names for better error messages
- Added buildDetailedErrorMessage() method that generates a comprehensive
  error report including:
  - The POM file path
  - The number of parsers attempted
  - Each parser's error with line/column information when available
  - The default XML reader's error
- Updated all call sites to use Map.of() instead of List.of()

This improves debugging when using alternative POM formats by showing
exactly why each parser failed, rather than just the final XML error.
@gnodet gnodet added bug Something isn't working mvn40 labels Dec 8, 2025
@gnodet
gnodet requested a review from cstamas December 9, 2025 08:08
@gnodet
gnodet merged commit 71261c2 into maven-4.0.x Dec 9, 2025
24 checks passed
@gnodet
gnodet deleted the improve/model-processor-error-reporting branch December 9, 2025 19:52
@github-actions github-actions Bot added this to the 4.0.0 milestone Dec 9, 2025
gnodet added a commit to gnodet/maven that referenced this pull request Dec 9, 2025
…apache#11529)

When multiple model parsers are registered (e.g., for YAML or TOML POMs)
and all parsers fail to parse a POM file, the error message now provides
detailed information about each parser's failure.

Changes:
- Changed modelParsers from List to Map<String, ModelParser> to preserve
  parser names for better error messages
- Added buildDetailedErrorMessage() method that generates a comprehensive
  error report including:
  - The POM file path
  - The number of parsers attempted
  - Each parser's error with line/column information when available
  - The default XML reader's error
- Updated all call sites to use Map.of() instead of List.of()

This improves debugging when using alternative POM formats by showing
exactly why each parser failed, rather than just the final XML error.

(cherry picked from commit 71261c2)

# Conflicts:
#	impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultPluginXmlFactoryTest.java
@gnodet

gnodet commented Dec 9, 2025

Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
master

Questions ?

Please refer to the Backport tool documentation

gnodet added a commit that referenced this pull request Dec 9, 2025
…#11529) (#11532)

When multiple model parsers are registered (e.g., for YAML or TOML POMs)
and all parsers fail to parse a POM file, the error message now provides
detailed information about each parser's failure.

Changes:
- Changed modelParsers from List to Map<String, ModelParser> to preserve
  parser names for better error messages
- Added buildDetailedErrorMessage() method that generates a comprehensive
  error report including:
  - The POM file path
  - The number of parsers attempted
  - Each parser's error with line/column information when available
  - The default XML reader's error
- Updated all call sites to use Map.of() instead of List.of()

This improves debugging when using alternative POM formats by showing
exactly why each parser failed, rather than just the final XML error.

(cherry picked from commit 71261c2)

# Conflicts:
#	impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultPluginXmlFactoryTest.java
@gnodet gnodet modified the milestones: 4.0.0, 4.0.0-rc-6 Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mvn40

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants