Resolve error thrown for sensitive values#17826
Conversation
|
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! |
Summary of ChangesHello @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
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 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 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
|
There was a problem hiding this comment.
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.
| try { | ||
| await keychain.deleteSecret(settingToUpdate.envVar); | ||
| } catch { | ||
| // Ignore if secret does not exist | ||
| } |
There was a problem hiding this comment.
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
- When catching exceptions, log the detailed error for debugging instead of providing only a generic error message.
|
Size Change: +152 B (0%) Total Size: 23.5 MB ℹ️ View Unchanged
|
|
/patch preview |
|
✅ Patch workflow(s) dispatched successfully! 📋 Details:
🔗 Track Progress: |
|
🚀 Patch PR Created! 📋 Patch Details:
📝 Next Steps:
🔗 Track Progress: |
|
🚀 Patch Release Started! 📋 Release Details:
⏳ Status: The patch release is now running. You'll receive another update when it completes. 🔗 Track Progress: |
|
✅ Patch Release Complete! 📦 Release Details:
🎉 Status: Your patch has been successfully released and published to npm! 📝 What's Available:
🔗 Links: |
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