Skip to content

fix(cli): preserve extension rollback and end startup phase#25654

Open
KoushikAD1234 wants to merge 1 commit intogoogle-gemini:mainfrom
KoushikAD1234:fix/extensions-update-keychain-21560
Open

fix(cli): preserve extension rollback and end startup phase#25654
KoushikAD1234 wants to merge 1 commit intogoogle-gemini:mainfrom
KoushikAD1234:fix/extensions-update-keychain-21560

Conversation

@KoushikAD1234
Copy link
Copy Markdown

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:

  • it did not create a real backup of the installed extension before attempting the update
  • it wrapped the original update failure in a misleading "Updated extension not found" error

This 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/finally so the load_builtin_commands startup 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

  1. 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.

  2. Run the full preflight checks:
    npm run preflight
    Expected result: all checks pass.

  3. Optional manual verification:

    • use a setup where an extension update fails during install
    • run gemini extensions update
    • confirm the installed extension remains intact after the failure
    • confirm the surfaced error reflects the real underlying cause instead of "Updated extension not found"

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

One correction: for Noted breaking changes, if there are no breaking changes, leave it unchecked. So better version is this line:

- [ ] Noted breaking changes (if any)

Everything else can stay as above.

So final checklist section should be:

## Pre-Merge Checklist

- [ ] Updated relevant documentation and README (if needed)
- [x] Added/updated tests (if needed)
- [ ] Noted breaking changes (if any)
- [x] Validated on required platforms/methods:
  - [x] MacOS
    - [x] npm run
    - [ ] npx
    - [ ] Docker
    - [ ] Podman
    - [ ] Seatbelt
  - [ ] Windows
    - [ ] npm run
    - [ ] npx
    - [ ] Docker
  - [ ] Linux
    - [ ] npm run
    - [ ] npx
    - [ ] Docker

@KoushikAD1234 KoushikAD1234 requested a review from a team as a code owner April 19, 2026 09:29
@gemini-code-assist
Copy link
Copy Markdown
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 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

  • Extension Update Robustness: Improved the extension update process by creating a backup of the existing extension before attempting an update, ensuring it can be restored if the installation fails.
  • Error Reporting: Updated the rollback mechanism to surface the actual underlying error instead of a generic 'Updated extension not found' message.
  • Startup Profiling: Wrapped builtin command loading in a try/finally block to ensure the startup profiler phase is correctly terminated even if command loading encounters an exception.
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.

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.

Copy link
Copy Markdown
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 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.

@gemini-cli gemini-cli bot added priority/p1 Important and should be addressed in the near term. area/extensions Issues related to Gemini CLI extensions capability help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/extensions Issues related to Gemini CLI extensions capability help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p1 Important and should be addressed in the near term.

Projects

None yet

1 participant