Skip to content

Conversation

@kairosci
Copy link

This PR ensures that toolbox rm and toolbox rmi exit with a non-zero status code if any error occurs during the removal process.

Previously, these commands would print an error message but continue execution and exit with 0, which could be misleading for scripts and automation.

@kairosci kairosci requested a review from debarshiray as a code owner January 10, 2026 17:15
@gemini-code-assist
Copy link

Summary of Changes

Hello @kairosci, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue where the toolbox rm and toolbox rmi commands would exit with a success status (zero) even when individual removal operations failed. By introducing logic to track and report any failures during the removal process, the commands now correctly signal an error through a non-zero exit status. This enhancement significantly improves the reliability of these commands, especially when used in automated scripts, ensuring that failures are properly detected and handled.

Highlights

  • Improved Error Reporting for rm Command: The toolbox rm command now correctly exits with a non-zero status code if any container removal operation fails, rather than silently continuing and exiting with a zero status.
  • Improved Error Reporting for rmi Command: Similarly, the toolbox rmi command now ensures a non-zero exit status if any image removal operation encounters an error.
  • Enhanced Scripting Reliability: These changes prevent scripts and automation from misinterpreting partial or complete failures as successful operations, leading to more robust command-line interactions.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

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 addresses an important issue where toolbox rm and toolbox rmi would not return a non-zero exit code on failure, which is problematic for scripting. The changes introduce a flag, attemptFailed, to track failures within the loops for removing containers and images, and then return a general error if any failure occurred. This correctly solves the problem for removing items by name.

However, the same logic has not been applied when the --all flag is used. In both rm and rmi commands, if removing an item fails within the --all loop, an error is printed, but the command will still exit with a success code (0). This is inconsistent with the goal of this pull request. To make the behavior consistent, I recommend applying the same attemptFailed logic to the blocks handling the --all flag for both commands.

containerObj, err := podman.InspectContainer(container)
if err != nil {
attemptFailed = true
fmt.Fprintf(os.Stderr, "Error: failed to inspect container %s\n", container)

Choose a reason for hiding this comment

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

medium

The error from podman.InspectContainer is discarded here. Including it in the output would provide more context about why the inspection failed, which is useful for debugging. The err variable likely contains detailed information from the underlying podman command.

Suggested change
fmt.Fprintf(os.Stderr, "Error: failed to inspect container %s\n", container)
fmt.Fprintf(os.Stderr, "Error: failed to inspect container %s: %v\n", container, err)

Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
@kairosci kairosci force-pushed the fix/rm-rmi-exit-status branch from bbfdc4a to b4ea175 Compare January 10, 2026 17:18
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