Fix duplicate model problem reporting, fixes #12691 - #12707
Conversation
gnodet
left a comment
There was a problem hiding this comment.
Clean, well-scoped fix for the duplicate model problem reporting regression introduced in #10975. The root cause is correctly identified: DefaultMaven.buildGraph() logs problem details from ModelProblem.getMessage() (which falls back to the exception message when its own message is null), and then DefaultExceptionHandler independently rebuilds the same details from getResults(), producing every model problem twice.
Reverting the exception message to the short static string is the right fix — it targets the duplication at its source without changing the higher-risk logging or exception handling paths. The test deletion is appropriate since all five methods validated the detailed message formatting being removed.
Worth noting: the regression was also backported to maven-4.0.x via commit b8a0ae0, so a backport of this fix is warranted there as well.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
rmannibucau
left a comment
There was a problem hiding this comment.
Can be worth a test showing the fixed issue to ensure it doesn't come back, the pr just validates an impl detail not the feature so bug can pop up again any time IMHO
|
Hello, I added the test. The test covers both paths directly: it verifies that |
gnodet
left a comment
There was a problem hiding this comment.
The new regression test properly addresses @rmannibucau's feedback — it validates user-facing behavior (no duplicate error rendering in console output), not just implementation details.
What the test covers:
- Exercises the real
DefaultExceptionHandler.handleException()pipeline (the same code path used byMavenInvoker.doExecute()in production) - Verifies
ProjectBuildingException.getMessage()returns only the short summary (preventing duplication when logged alongside handler output) - Verifies the handler's
ExceptionSummarytree contains each problem detail exactly once viacountOccurrences(flatten(summary), ...) - The
flatten()helper simulates whatMavenInvoker.logSummary()does in production
The original fix remains correct and complete. The deletion of ProjectBuildingExceptionTest is appropriate since it tested the detailed formatting behavior introduced in #10975, which this PR reverts.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
Summary
Fixes #12691 by removing the duplicate rendering of model problems introduced in
ProjectBuildingException#createMessage(...).The detailed per-project diagnostics were added to the exception message in #10975. However,
DefaultExceptionHandleralready reconstructs and renders the same information fromProjectBuildingException#getResults(), so the new exception message caused the same diagnostics to be printed twice.This change restores the previous behavior by reverting
ProjectBuildingException#createMessage(List<ProjectBuildingResult>)to return the short summary message, leaving the existing rendering inDefaultExceptionHandleras the single source of detailed diagnostics.ProjectBuildingExceptionTestis removed because it was introduced to validate the detailed formatting added in #10975. Reverting that behavior makes the test obsolete; the remaining behavior is simply returning the generic exception message.Before
After
Each model problem is now reported once again, matching the pre-4.0.0-rc-6 behavior.
Note: Please consider backporting this change to maven-4.0.x, as it fixes a regression affecting the 4.0.x release line.