Skip to content

fix(cli): treat SANDBOX=0/false as not inside sandbox#21601

Closed
MohammedADev wants to merge 10 commits into
google-gemini:mainfrom
MohammedADev:fix/21600-sandbox-zero-sentinel
Closed

fix(cli): treat SANDBOX=0/false as not inside sandbox#21601
MohammedADev wants to merge 10 commits into
google-gemini:mainfrom
MohammedADev:fix/21600-sandbox-zero-sentinel

Conversation

@MohammedADev

Copy link
Copy Markdown
Contributor

Summary

Fixes sandbox initialization logic so SANDBOX='0' and SANDBOX='false' are not treated as “already inside sandbox”.

before any non-empty SANDBOX value short circuited the sandbox setup. This could unintentionally bypass explicit sandbox requests (for example, GEMINI_SANDBOX='docker').

Details

Root cause
Inpackages/cli/src/config/sandboxConfig.ts, the inside-sandbox guard used a generic truthy check:
if (process.env['SANDBOX']) return ''

Because '0' is a non-empty string, it evaluated truthy and incorrectly disabled sandbox initialization.

Related Issues

fixes #21600

How to Validate

npm run test --workspace @google/gemini-cli -- src/config/sandboxConfig.test.ts
Confirm test passes, including:
should not treat SANDBOX='0' as already inside sandbox

Optional manual behavior check if you want,
Set SANDBOX=0
Set GEMINI_SANDBOX=docker
Confirm sandbox config no longer gets skipped due to the inside the sandbox guard.

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
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@MohammedADev MohammedADev requested a review from a team as a code owner March 8, 2026 01:39
@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 addresses a critical bug in the CLI's sandbox configuration where non-empty string values for the SANDBOX environment variable, such as '0' or 'false', were incorrectly treated as truthy, causing the sandbox setup to be skipped. The changes ensure that the system accurately determines whether it's already within a sandbox, allowing explicit sandbox requests to be honored as intended.

Highlights

  • Sandbox Environment Variable Handling: Modified the sandbox initialization logic to correctly interpret SANDBOX='0' and SANDBOX='false' as indicators that the environment is not already sandboxed. This prevents unintended bypasses of explicit sandbox configurations.
Changelog
  • packages/cli/src/config/sandboxConfig.test.ts
    • Added a new test case to verify that SANDBOX='0' does not trigger the "already inside sandbox" condition, ensuring proper sandbox initialization.
  • packages/cli/src/config/sandboxConfig.ts
    • Modified the getSandboxCommand function to explicitly check for SANDBOX environment variable values of '0' or 'false' (case-insensitive) to correctly identify when the system is not already in a sandbox.
Activity
  • The author has provided detailed steps for validation, including running specific tests and an optional manual behavior check.
  • The pre-merge checklist indicates that relevant documentation and tests have been updated, and the changes have been validated on Windows (npm run) and Linux (npm run).
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.

@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 correctly addresses a bug where SANDBOX values of '0' or 'false' were improperly treated as being inside a sandbox. The logic change is sound and is accompanied by a new test case that validates the fix. My review includes one suggestion to align the new test with the repository's testing conventions.

Comment thread packages/cli/src/config/sandboxConfig.test.ts Outdated
@MohammedADev

Copy link
Copy Markdown
Contributor Author

Hi everyone, bumping this PR for code owner review #21601

This has been pending for ~2 weeks and is currently blocked on required maintainer approval. All prior feedback has been addressed and the branch is up to date.

Could someone take a look when available? Thanks in advance!

@gemini-cli

gemini-cli Bot commented Mar 22, 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 have updated our contribution policy (see Discussion #17383).

We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'.

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 and for being part of our community!

@gemini-cli gemini-cli Bot closed this Mar 22, 2026
@sripasg sripasg added the size/s A small PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s A small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: SANDBOX='0' incorrectly disables sandbox initialization in loadSandboxConfig

2 participants