fix(cli): parse commented settings.json in memory bootstrap#28219
fix(cli): parse commented settings.json in memory bootstrap#28219syf2211 wants to merge 1 commit into
Conversation
getMemoryNodeArgs() read ~/.gemini/settings.json with JSON.parse, which throws on comment-bearing configs that the rest of the CLI accepts via strip-json-comments. The silent catch left autoConfigureMemory at its default true, ignoring advanced.autoConfigureMemory: false. Use the same comment-stripping parse helper as settings loading and add a regression test for commented JSON. Fixes google-gemini#28206
|
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. |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
Summary of ChangesHello, 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 an issue where the CLI's parent process failed to correctly parse 'settings.json' files containing comments, causing it to ignore user-defined memory configurations. By replacing the standard 'JSON.parse' with a comment-aware parsing utility, the CLI now correctly interprets configuration files, ensuring consistent behavior across the application. Highlights
Using Gemini Code AssistThe 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
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 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
|
|
📊 PR Size: size/S
|
|
recheck |
There was a problem hiding this comment.
Code Review
This pull request introduces a utility function parseJsonWithComments in packages/cli/src/utils/parseJsonWithComments.ts that strips comments from a JSON string before parsing it. It updates packages/cli/index.ts to dynamically import and use this utility when reading the CLI settings file, allowing users to include comments in their settings.json. Additionally, a corresponding unit test file is added to verify this behavior. There are no review comments, so I have no feedback to provide.
|
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. |
Summary
Fix
getMemoryNodeArgs()so the lightweight CLI parent process can read comment-bearingsettings.jsonfiles without silently falling back to default memory auto-configuration.Motivation
The parent process reads
~/.gemini/settings.jsonbefore relaunching the full CLI. It used rawJSON.parse, which throws on JSON comments. The emptycatchblock leftautoConfigureMemoryat its defaulttrue, so users who setadvanced.autoConfigureMemory: falsein a commented config were ignored.The rest of the CLI already accepts commented JSON via
strip-json-comments(e.g.settings.ts).Fixes #28206
Changes
packages/cli/index.tsparseJsonWithCommentsingetMemoryNodeArgs()packages/cli/src/utils/parseJsonWithComments.tsJSON.parse(stripJsonComments(raw))packages/cli/src/utils/parseJsonWithComments.test.tsautoConfigureMemory: falseTests
npm run build --workspace @google/gemini-cli-corenpm run test -- src/utils/parseJsonWithComments.test.ts— 1 passednpx eslint index.ts src/utils/parseJsonWithComments.ts src/utils/parseJsonWithComments.test.ts— passedNotes
npm run preflightwas not run locally due to monorepo build time; targeted tests and lint were run on changed files.