fix(cli): preserve extension rollback and end startup phase#25654
fix(cli): preserve extension rollback and end startup phase#25654KoushikAD1234 wants to merge 1 commit intogoogle-gemini:mainfrom
Conversation
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 improves the reliability of the CLI extension update flow and fixes a potential issue with startup profiling. By implementing proper backup and restore logic during updates, it prevents data loss when installations fail and provides clearer error feedback. Additionally, it ensures that the startup profiler correctly ends its tracking phase regardless of whether command loading succeeds or fails, preventing misleading startup warnings. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request improves the robustness of extension updates and command loading. Key changes include backing up extensions to a temporary directory before updates, improving error messages during update failures, and ensuring the startup profiler correctly terminates using a try-finally block in the command loader. Corresponding unit tests were added to verify these improvements. I have no feedback to provide.
Fixes #21560
Summary
Fix extension update failures to preserve the installed extension for rollback, surface the real underlying error, and ensure builtin command startup profiling always ends even when command loading throws.
Details
The extension update flow was backing out of failures incorrectly:
"Updated extension not found"errorThis change updates the rollback path to back up the installed extension first, restore from that backup on failure, and report the underlying error directly.
It also wraps builtin command loading in
try/finallyso theload_builtin_commandsstartup profiler phase is always ended. That prevents repeated startup warnings about the phase already being active or never ending after a command loading exception.Related Issues
Fixes #21560
How to Validate
Run the focused tests:
npm test --workspace packages/cli -- src/config/extensions/update.test.ts src/services/BuiltinCommandLoader.test.ts
Expected result: both test files pass.
Run the full preflight checks:
npm run preflight
Expected result: all checks pass.
Optional manual verification:
Pre-Merge Checklist
One correction: for
Noted breaking changes, if there are no breaking changes, leave it unchecked. So better version is this line: