Skip to content

Resolve error thrown for sensitive values#17826

Merged
chrstnb merged 1 commit into
mainfrom
cb/fixrequiredsensitive
Jan 29, 2026
Merged

Resolve error thrown for sensitive values#17826
chrstnb merged 1 commit into
mainfrom
cb/fixrequiredsensitive

Conversation

@chrstnb

@chrstnb chrstnb commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Summary

We were throwing an error when passing an empty value to the keychain. To resolve, we should not be passing empty sensitive values to the keychain.

Details

Related Issues

How to Validate

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

@chrstnb chrstnb requested a review from a team as a code owner January 28, 2026 22:31
@gemini-cli

gemini-cli Bot commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Hi @chrstnb, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @chrstnb, 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 refines the handling of sensitive configuration values, specifically addressing an issue where empty values could lead to errors when interacting with the keychain. The changes ensure that sensitive settings are only persisted when they have a non-empty value, and that providing an empty value for an existing sensitive setting will result in its removal from the keychain. This improves the stability and correctness of how sensitive data is managed within the application.

Highlights

  • Sensitive Value Handling: Empty sensitive values are no longer stored in the keychain during initial setup, preventing potential errors.
  • Sensitive Value Deletion: Updating a sensitive setting with an empty value now correctly triggers the deletion of that secret from the keychain.
  • Robustness: The system now gracefully handles attempts to delete non-existent sensitive secrets from the keychain without throwing errors.
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 addresses an issue where an error was thrown when passing an empty sensitive value to the keychain. The solution involves preventing empty sensitive values from being set and deleting existing sensitive values when they are updated with an empty string. The changes are logical and include corresponding tests. However, I've identified a high-severity issue in the error handling for deleting secrets. The current implementation uses a broad try...catch block that could mask critical errors, such as keychain unavailability, leading to silent failures. I have provided a suggestion to make the error handling more specific, robust, and to ensure detailed errors are logged for debugging before re-throwing, aligning with best practices for exception handling.

Comment on lines +236 to +240
try {
await keychain.deleteSecret(settingToUpdate.envVar);
} catch {
// Ignore if secret does not exist
}

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.

high

This try...catch block is too broad as it will swallow all errors from keychain.deleteSecret, including critical ones like the keychain being unavailable. This can lead to silent failures. The catch block should only ignore the specific error for a non-existent secret, log other errors for debugging, and re-throw them.

      try {
        await keychain.deleteSecret(settingToUpdate.envVar);
      } catch (e) {
        // It's okay if the secret didn't exist. Log and re-throw other errors.
        if (!(e instanceof Error && e.message.startsWith('No secret found for key:'))) {
          console.error(`Failed to delete secret ${settingToUpdate.envVar}:`, e);
          throw e;
        }
      }
References
  1. When catching exceptions, log the detailed error for debugging instead of providing only a generic error message.

@github-actions

Copy link
Copy Markdown

Size Change: +152 B (0%)

Total Size: 23.5 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 23.5 MB +152 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

@gemini-cli gemini-cli Bot added the priority/p1 Important and should be addressed in the near term. label Jan 28, 2026
@chrstnb chrstnb added this pull request to the merge queue Jan 29, 2026
Merged via the queue into main with commit 42eedc9 Jan 29, 2026
28 checks passed
@chrstnb chrstnb deleted the cb/fixrequiredsensitive branch January 29, 2026 15:11
@chrstnb

chrstnb commented Jan 29, 2026

Copy link
Copy Markdown
Contributor Author

/patch preview

@github-actions

Copy link
Copy Markdown

Patch workflow(s) dispatched successfully!

📋 Details:

  • Channels: preview
  • Commit: 42eedc91843235ab2f533d0a0020a667a6a5adfd
  • Workflows Created: 1

🔗 Track Progress:

@github-actions

Copy link
Copy Markdown

🚀 Patch PR Created!

📋 Patch Details:

📝 Next Steps:

  1. Review and approve the hotfix PR: #17907
  2. Once merged, the patch release will automatically trigger
  3. You'll receive updates here when the release completes

🔗 Track Progress:

@github-actions

Copy link
Copy Markdown

🚀 Patch Release Started!

📋 Release Details:

  • Environment: prod
  • Channel: preview → publishing to npm tag preview
  • Version: v0.27.0-preview.2
  • Hotfix PR: Merged ✅
  • Release Branch: release/v0.27.0-preview.2-pr-17826

⏳ Status: The patch release is now running. You'll receive another update when it completes.

🔗 Track Progress:

@github-actions

Copy link
Copy Markdown

Patch Release Complete!

📦 Release Details:

🎉 Status: Your patch has been successfully released and published to npm!

📝 What's Available:

🔗 Links:

sidwan02 pushed a commit to sidwan02/gemini-cli-gemma that referenced this pull request Feb 6, 2026
kuishou68 pushed a commit to iOfficeAI/gemini-cli-pro that referenced this pull request Feb 27, 2026
@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/p1 Important and should be addressed in the near term. size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants