Skip to content

fix(maven): ignore generic build failure banners in log handler (#6870) - #6871

Merged
squakez merged 1 commit into
apache:mainfrom
Ankitraj-sharma:fix/maven-log-error
Oct 8, 2026
Merged

squakez merged 1 commit into
apache:mainfrom
Ankitraj-sharma:fix/maven-log-error

Conversation

@Ankitraj-sharma

Copy link
Copy Markdown

Fixes #6870

Motivation

In newer runner images (and modern Maven 3.9+), Maven outputs the failure summary banner [ERROR] BUILD FAILURE and divider lines [ERROR] ------------------------------------------------------------------------ with log level ERROR rather than INFO.

Because pkg/util/command.go's scan records the first non-empty error message returned by LogHandler, the generic banner "BUILD FAILURE" was permanently recorded as the command's error message, shadowing the actual informative failure reason that follows (e.g. "The goal you specified requires a project to execute but there is no POM in this directory"). This caused TestRunAndLogErrorMvn to fail with:

Error "BUILD FAILURE: exit status 1" does not contain "The goal you specified requires a project to execute but there is no POM in this directory"

It also resulted in Maven failures in the builder (pkg/builder/jib.go) reporting only "BUILD FAILURE: exit status 1" without the actionable error reason.

Modifications

  • Updated LogHandler in pkg/util/maven/maven_log.go to ignore non-diagnostic Maven banners (BUILD FAILURE, BUILD ERROR), separator lines (---...), and execution summary timings (Total time:, Finished at:) so that the actual root cause message is returned to the caller.
  • Handled both ERROR and FATAL levels consistently with normalizeLog.
  • In pkg/util/maven/maven_log_test.go:
    • Added a skip check in TestRunAndLogErrorMvn if mvn is not present in PATH.
    • Added unit test TestLogHandler verifying banner and separator filtering.
    • Added unit test TestLogHandlerMavenFailureSequence verifying that the informative error is correctly extracted from the Maven 3.9+ failure stream.

@squakez squakez 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.

I think we can make it simpler that this. We can just remove the "ErrorContains" condition and avoid checking the reason. In the future we will probably refactor this part, so, no need to put more logic there.

…pache#6870)

Remove the ErrorContains assertion in TestRunAndLogErrorMvn to avoid asserting
the specific failure reason string from Maven's failure banner, keeping the
assertion focused on the error occurrence.

Signed-off-by: Ankit raj sharma <ankitrajsharma666@gmail.com>
@squakez

squakez commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Check failure happens in build main (used for coverage diff).

@squakez
squakez merged commit 3782027 into apache:main Oct 8, 2026
12 of 14 checks passed
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.

TestRunAndLogErrorMvn test error

2 participants