Skip to content

Fix #18834: use docker inspect exit code instead of stdout parsing - #27428

Closed
LifeJiggy wants to merge 1 commit into
google-gemini:mainfrom
LifeJiggy:fix/18834-sandbox-image-exists
Closed

Fix #18834: use docker inspect exit code instead of stdout parsing#27428
LifeJiggy wants to merge 1 commit into
google-gemini:mainfrom
LifeJiggy:fix/18834-sandbox-image-exists

Conversation

@LifeJiggy

Copy link
Copy Markdown

Summary

Fix sandbox imageExists returning false negatives when Docker outputs image names to stderr (e.g. with DOCKER_BUILDKIT). Switch from parsing docker images -q stdout to using docker inspect --type=image exit code.

Details
docker images -q may write the image name to stderr when DOCKER_BUILDKIT=1 is set, causing the old stdout-based parsing to return a false negative. The sandbox would then attempt to pull the image unnecessarily. The fix uses docker inspect --type=image and checks the exit code, which is reliable regardless of output channel.

Related Issues
Fixes #18834

How to Validate

  1. cd packages/cli
  2. npx vitest run src/utils/sandbox.test.ts — all 8 tests pass
  3. If Docker is available: set DOCKER_BUILDKIT=1, run sandbox operation — no spurious pull

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
  • MacOS
  • Windows
  • Linux (via CI)

@LifeJiggy
LifeJiggy requested a review from a team as a code owner May 25, 2026 05:00
@gemini-cli gemini-cli Bot added priority/p1 Important and should be addressed in the near term. area/core Issues related to User Interface, OS Support, Core Functionality area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt labels May 25, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 improves the reliability of the sandbox image existence check by switching from parsing command output to checking the exit code of the Docker inspection command. This ensures that the system correctly identifies image presence even when environment variables like DOCKER_BUILDKIT are enabled, which previously caused output to be redirected to stderr and triggered unnecessary image pulls.

Highlights

  • Improved Docker image existence check: Replaced the unreliable stdout parsing of 'docker images -q' with 'docker inspect --type=image', which uses the command's exit code to determine if an image exists.
  • Enhanced reliability with DOCKER_BUILDKIT: The change prevents false negatives that occurred when DOCKER_BUILDKIT=1 caused image names to be output to stderr instead of stdout.
  • Test suite updates: Updated all relevant unit tests in sandbox.test.ts to reflect the new inspection logic and simplified the mocking of the spawn process.
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 the 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 counterproductive. 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.

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.

@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 the imageExists utility in packages/cli to use docker inspect --type=image instead of docker images -q for checking the existence of a sandbox image. The implementation now relies on the process exit code rather than parsing stdout, and includes stdio: 'ignore' to suppress output. Corresponding test mocks and assertions in sandbox.test.ts have been updated to reflect these changes. I have no feedback to provide as there were no review comments to evaluate.

@LifeJiggy
LifeJiggy force-pushed the fix/18834-sandbox-image-exists branch from 8bc9dba to 9e19863 Compare May 25, 2026 05:17
@LifeJiggy

Copy link
Copy Markdown
Author

@scidomino, @abhipatel12 , @bbiggs PTAL

@LifeJiggy
LifeJiggy force-pushed the fix/18834-sandbox-image-exists branch from 9e19863 to 13facc0 Compare May 29, 2026 10:57
@scidomino

Copy link
Copy Markdown
Collaborator

Please do not ping individual maintainers. Our inboxes are overfull and many of us have been assigned to other project. I appreciate that it's frustrating but this will be reviewed by the normal process or not at all.

@LifeJiggy

Copy link
Copy Markdown
Author

@scidomino

Understood. I apologize for pinging multiple maintainers.

I won't ping individuals again and will respect the normal review process going forward.

Thank you.

@gemini-cli

gemini-cli Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'.

This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

@github-actions github-actions Bot added the size/m A medium sized PR label Jun 2, 2026
…ut parsing

The old implementation parsed stdout from docker images -q which could
produce false negatives when Docker outputs image names to stderr (e.g.
with DOCKER_BUILDKIT). Switch to docker inspect --type=image and check
exit code directly.

Also update all test mocks to match the new args and remove now-unused
stdout data emission.
@LifeJiggy
LifeJiggy force-pushed the fix/18834-sandbox-image-exists branch from 04fcc1f to 7a0353a Compare June 8, 2026 05:39
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 127
  • Additions: +43
  • Deletions: -84
  • Files changed: 2

@LifeJiggy

Copy link
Copy Markdown
Author

Friendly ping here. this PR now have 1 approval

please let this pass through before the bot automatically close it

@ALL PTAL

@LifeJiggy

Copy link
Copy Markdown
Author

/gemini help

@gemini-code-assist

Copy link
Copy Markdown
Contributor
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 the 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 counterproductive. 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.

@gemini-cli

gemini-cli Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

@LifeJiggy

Copy link
Copy Markdown
Author

**scidomino ** commente

this hurt that depsite trying to saved this PR and requesting for review

now its closed.

@sin325

sin325 commented Jun 9, 2026 via email

Copy link
Copy Markdown

@LifeJiggy

Copy link
Copy Markdown
Author

@sin325 @gemini-cli-bot

Hey team,

This PR (#27428) already had 1 approval and I pushed a final commit on June 8th to address feedback.

I understand the 14-day policy, but it feels a bit harsh to close a PR that was actively being worked on and had maintainer approval.

Can we reopen this PR so it can get a final review and be merged?

It fixes #18834 and already received approval. Happy to make any additional changes needed.

Thanks!

@lucasrangit

lucasrangit commented Jun 9, 2026

Copy link
Copy Markdown

Hi @LifeJiggy , I'm not a maintainer but I reviewed your fix because I am impacted by the issue #18834.

I think the bot there wants someone to retest with the latest version to see if the issue persists. Can you do that? Maybe the correct process is to convince the bot that the issue is valid and it will label it with help wanted so you can work on it? If you are up for, you can try fixing a help wanted issue from https://github.com/google-gemini/gemini-cli/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22 to see if that's the correct process.

Thanks for your efforts.

@LifeJiggy

Copy link
Copy Markdown
Author

@lucasrangit

Thanks for taking the time to review and for the feedback.

I already retested this fix recently (June 8th push) with the latest main branch and it resolves the issue cleanly (using docker inspect exit code instead of fragile stdout parsing).

The PR had 1 approval before the bot closed it. Would really appreciate if a maintainer could reopen it for final review.

@sin325 Any chance we can get this reopened? Happy to address any remaining feedback.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt priority/p1 Important and should be addressed in the near term. size/m A medium sized PR status/pr-nudge-sent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix for "Sandbox image ... is missing or could not be pulled"

4 participants