Skip to content

fix(settings): display objects as JSON instead of [object Object]#21458

Merged
jacob314 merged 3 commits intogoogle-gemini:mainfrom
Zheyuan-Lin:fix/settings-object-display
Mar 9, 2026
Merged

fix(settings): display objects as JSON instead of [object Object]#21458
jacob314 merged 3 commits intogoogle-gemini:mainfrom
Zheyuan-Lin:fix/settings-object-display

Conversation

@Zheyuan-Lin
Copy link
Contributor

@Zheyuan-Lin Zheyuan-Lin commented Mar 6, 2026

Summary

This PR fixes a bug where settings with object values were displayed as [object Object] in the CLI. They are now correctly stringified to JSON for better readability.

Details

  • Modified getDisplayValue in packages/cli/src/utils/settingsUtils.ts to detect object types and use
    JSON.stringify() to display their content.
  • Added a comprehensive unit test in packages/cli/src/utils/settingsUtils.test.ts to verify that both empty
    objects and objects with properties are displayed as valid JSON strings.

Related Issues

Fixes #21202

How to Validate

  1. Open the Gemini CLI.
  2. Inspect a setting that contains an object value (e.g., an experimental configuration like
    experimental.gemmaModelRouter).
  3. Verify that the value appears as a JSON string (e.g., {} or {"enabled":true}) instead of the generic
    [object Object] string.
  4. Run the updated unit tests to ensure no regressions:
    1 npm test -w @google/gemini-cli -- src/utils/settingsUtils.test.ts

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
    • Linux

@Zheyuan-Lin Zheyuan-Lin requested review from a team as code owners March 6, 2026 21:30
@gemini-code-assist
Copy link
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 primarily resolves a display bug in the CLI, ensuring that complex settings with object values are now presented as readable JSON strings rather than generic object representations. Concurrently, it significantly expands the CLI's sandboxing capabilities by integrating gVisor/runsc, offering a more robust and isolated execution environment for operations on Linux systems. This dual enhancement improves both user experience through clearer output and operational security through advanced sandboxing.

Highlights

  • Settings Display Enhancement: Object-valued settings in the CLI are now correctly displayed as JSON strings, resolving an issue where they previously appeared as '[object Object]'.
  • gVisor/runsc Sandboxing Integration: Introduced support for gVisor/runsc as a new, highly isolated sandboxing option for Linux, leveraging Docker with the '--runtime=runsc' flag.
  • Improved Sandbox Configuration and Validation: Enhanced sandbox configuration logic to include 'runsc' as a valid command, with added validation for platform compatibility (Linux-only) and Docker dependency.
  • Comprehensive Test Coverage: New unit tests were added to verify the correct JSON stringification of object settings and to ensure the proper functioning and error handling of gVisor/runsc sandboxing.
Changelog
  • docs/cli/sandbox.md
    • Updated documentation to include gVisor/runsc as a sandboxing option and its configuration.
  • packages/cli/src/config/sandboxConfig.test.ts
    • Extended sandbox configuration tests to include 'runsc' validation, platform checks, and Docker dependency.
  • packages/cli/src/config/sandboxConfig.ts
    • Added 'runsc' to the list of valid sandbox commands.
    • Implemented specific validation for 'runsc' sandboxing, including Linux-only support and Docker dependency checks.
  • packages/cli/src/utils/sandbox.test.ts
    • Added new test cases to verify the correct invocation of Docker with '--runtime=runsc' when gVisor is selected.
  • packages/cli/src/utils/sandbox.ts
    • Modified sandbox execution to correctly handle 'runsc' by using 'docker' with the '--runtime=runsc' flag.
    • Adjusted proxy command handling to prevent command injection and ensure correct argument parsing.
  • packages/cli/src/utils/settingsUtils.test.ts
    • Added unit tests to confirm that object settings are correctly displayed as JSON strings instead of '[object Object]'.
  • packages/cli/src/utils/settingsUtils.ts
    • Implemented logic to detect object-type settings and serialize them to JSON strings for display purposes.
  • packages/core/src/config/config.ts
    • Updated the 'SandboxConfig' interface to include 'runsc' as a permissible sandbox command.
Activity
  • The author updated relevant documentation and added/updated tests as part of the pre-merge checklist.
  • The changes were validated on MacOS.
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-cli gemini-cli bot added area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Mar 6, 2026
@psinha40898
Copy link
Contributor

I think you diffed extra files because you checked out this PR's branch from your previous PR.

You should checkout a new branch from main.

Copy link
Contributor

@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 introduces two main changes. First, it fixes a display bug where object-based settings were shown as [object Object], and now correctly displays them as JSON strings. Second, it adds support for runsc (gVisor) as a new sandboxing option, which includes a critical security fix for command injection when using a proxy command with container-based sandboxes. My review identifies a critical security issue where the command injection fix was not applied to all relevant code paths. A similar vulnerability remains in the sandbox-exec path, which needs to be addressed to ensure both sandbox paths are secure.

@Zheyuan-Lin Zheyuan-Lin force-pushed the fix/settings-object-display branch from a61bf19 to ba2a925 Compare March 6, 2026 21:34
@Zheyuan-Lin
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@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 fixes a bug where settings with object values were displayed as [object Object] by correctly serializing them to JSON for display. The change is implemented in getDisplayValue and is accompanied by a comprehensive unit test that covers both empty and populated objects. The fix is correct and well-tested.

Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

lgtm

@jacob314 jacob314 added this pull request to the merge queue Mar 9, 2026
Merged via the queue into google-gemini:main with commit 95074a1 Mar 9, 2026
27 checks passed
kunal-10-cloud pushed a commit to kunal-10-cloud/gemini-cli that referenced this pull request Mar 12, 2026
…ogle-gemini#21458)

Co-authored-by: Zheyuan <zlin252@emory.edu>
Co-authored-by: Jacob Richman <jacob314@gmail.com>
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
…ogle-gemini#21458)

Co-authored-by: Zheyuan <zlin252@emory.edu>
Co-authored-by: Jacob Richman <jacob314@gmail.com>
DavidAPierce pushed a commit that referenced this pull request Mar 16, 2026
…1458)

Co-authored-by: Zheyuan <zlin252@emory.edu>
Co-authored-by: Jacob Richman <jacob314@gmail.com>
yashodipmore pushed a commit to yashodipmore/geemi-cli that referenced this pull request Mar 21, 2026
…ogle-gemini#21458)

Co-authored-by: Zheyuan <zlin252@emory.edu>
Co-authored-by: Jacob Richman <jacob314@gmail.com>
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 help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings - utils should properly display Objects

3 participants