Skip to content

fix: correct pushed image logging for latest tag …#4511

Open
Rabie45 wants to merge 2 commits into
GoogleContainerTools:masterfrom
Rabie45:fix/4510-image-logging-missing-tags
Open

fix: correct pushed image logging for latest tag …#4511
Rabie45 wants to merge 2 commits into
GoogleContainerTools:masterfrom
Rabie45:fix/4510-image-logging-missing-tags

Conversation

@Rabie45

@Rabie45 Rabie45 commented Jun 23, 2026

Copy link
Copy Markdown

… ─╯

Replace image reference string formatting with toStringWithQualifier() for tagged images and avoid duplicate untagged entries in the success message.

Add a test covering latest and additional tags in build success logs.

Thank you for your interest in contributing! For general guidelines, please refer to
the contributing guide.

Please follow the guidelines below before opening an issue or a PR:

  • Ensure the issue was not already reported.
  • Create a new issue at https://github.com/GoogleContainerTools/jib/issues/new/choose if you are unable to find an existing issue addressing your problem. Make sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring.
  • Discuss the priority and potential solutions with the maintainers in the issue. The maintainers would review the issue and add a label "Accepting Contributions" once the issue is ready for accepting contributions.
  • Open a PR only if the issue is labeled with "Accepting Contributions", ensure the PR description clearly describes the problem and solution. Note that an open PR without an issues labeled with "Accepting Contributions" will not be accepted.
  • Verify that integration tests and unit tests are passing after the change.
  • Address all checkstyle issues. Refer to the style guide.

Fixes #4510 🛠️

Replace image reference string formatting with toStringWithQualifier()
for tagged images and avoid duplicate untagged entries in the success
message.

Add a test covering latest and additional tags in build success logs.
@google-cla

google-cla Bot commented Jun 23, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates JibBuildRunner to prevent duplicate tag entries in the build success message when a tag matches the target image's qualifier, and adds a corresponding unit test. Feedback on these changes highlights that the new test will fail because the default 'latest' qualifier is skipped in the loop, meaning the success message will contain 'repo/container' instead of 'repo/container:latest'. Additionally, it is recommended to fix a minor indentation issue and reverse the equality check to prevent a potential NullPointerException if additionalTags contains null values.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +259 to +263
Assert.assertTrue(successMessage.contains("repo/container:latest"));
Assert.assertTrue(successMessage.contains("repo/container:1.0.0-SNAPSHOT"));
Assert.assertTrue(successMessage.contains("repo/container:branch"));
long occurrences = successMessage.split("repo/container", -1).length - 1L;
Assert.assertEquals(3, occurrences);

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.

high

The assertion Assert.assertTrue(successMessage.contains("repo/container:latest")); will fail.

Why it fails:

  1. targetImageReference is parsed from "repo/container", which defaults to the "latest" tag. Its toString() representation is "repo/container" (without the :latest suffix).
  2. In JibBuildRunner.java, the loop skips the "latest" tag because tag.equals(targetImageReference.getQualifier()) evaluates to true (both are "latest").
  3. As a result, the success message is built as "Built and pushed image as repo/container, repo/container:1.0.0-SNAPSHOT, repo/container:branch".
  4. This string contains "repo/container" but does not contain "repo/container:latest".

To fix this, we should assert that "repo/container" is present, but "repo/container:latest" is not.

    Assert.assertTrue(successMessage.contains("repo/container"));
    Assert.assertFalse(successMessage.contains("repo/container:latest"));
    Assert.assertTrue(successMessage.contains("repo/container:1.0.0-SNAPSHOT"));
    Assert.assertTrue(successMessage.contains("repo/container:branch"));
    long occurrences = successMessage.split("repo/container", -1).length - 1L;
    Assert.assertEquals(3, occurrences);

Comment on lines +77 to +80
for (String tag : additionalTags) {
if (tag.equals(targetImageReference.getQualifier())) {
continue;
}

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.

medium

There is a minor indentation issue on line 77 (3 spaces instead of 4). Additionally, to prevent a potential NullPointerException if any element in additionalTags is null, it is safer to use targetImageReference.getQualifier().equals(tag) instead of tag.equals(...) since getQualifier() is guaranteed to return a non-null string.

Suggested change
for (String tag : additionalTags) {
if (tag.equals(targetImageReference.getQualifier())) {
continue;
}
for (String tag : additionalTags) {
if (targetImageReference.getQualifier().equals(tag)) {
continue;
}

   Use toStringWithQualifier() for the base image reference so the
   ':latest' tag is shown explicitly in the success message, reverse
   null-safe equality check for additional tag deduplication, and fix
   indentation on the for loop.
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.

logging issue: "built and pushed image as container" (tagless)

1 participant