Skip to content

fix(extensions): gate experiments in before hooks, prompt for upgrades, and default uninstall to false in ext:migrate - #11064

Merged
ajperel merged 2 commits into
mainfrom
ajp/fix-ext-migrate-audit
Sep 11, 2026
Merged

fix(extensions): gate experiments in before hooks, prompt for upgrades, and default uninstall to false in ext:migrate#11064
ajperel merged 2 commits into
mainfrom
ajp/fix-ext-migrate-audit

Conversation

@ajperel

@ajperel ajperel commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Description

Improves safety and execution flow in ext:migrate and functions:kits:install:

  • Early Experiment Gating: Moves experiment checks into .before() hooks on ext:migrate (extMigrationFeatures, kits, secretEnvParams) and functions:kits:install (kits) so execution fails fast before configuration, IAM, or scaffolding steps run.
  • Safe Extension Uninstallation: Updates the post-deploy extension uninstallation confirmation in ext:migrate to default to false, preventing unintended teardown of live extensions during non-interactive runs.
  • Extension Upgrade Prompts & Enforcement: Ensures extension specifications and version fallbacks are loaded before update checks. Outdated extensions now prompt for confirmation before upgrading in-place.

Scenarios Tested

  • Unit tests in src/commands/functions-kits-install.spec.ts verifying .before() hook experiment gating.
  • Unit tests in src/extensions/migrate.spec.ts verifying upgrade prompts, declined upgrade warnings, version fallbacks, and uninstall confirmation defaults.
  • npm run test
  • Manual migration of an out of date storage-resize-images extension.

Sample Commands

firebase ext:migrate --package @firebase-function-kits/storage-resize-images@next
firebase ext:migrate --package @firebase-function-kits/storage-resize-images@next --force

@ajperel
ajperel requested a review from wandamora September 9, 2026 23:46

@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 refactors the extension migration and function kits installation commands. Key changes include moving experiment assertions to command .before hooks, prompting users to upgrade outdated extension instances prior to migration (with a --force bypass), changing the default option for uninstalling migrated extensions to false, and adding comprehensive tests. The review feedback highlights a potential runtime crash in ensureInstanceUpToDate where instance.config is accessed without optional chaining, recommending defensive checks to handle cases where config might be undefined.

Comment thread src/extensions/migrate.ts
@ajperel
ajperel force-pushed the ajp/fix-ext-migrate-audit branch 3 times, most recently from e68352b to a26a54b Compare September 10, 2026 00:09
…s, and default uninstall to false in ext:migrate

Improves safety and execution flow in `ext:migrate` and `functions:kits:install`:

- **Early Experiment Gating**: Moves experiment checks into `.before()` hooks on `ext:migrate` (`extMigrationFeatures`, `kits`, `secretEnvParams`) and `functions:kits:install` (`kits`) so execution fails fast before configuration, IAM, or scaffolding steps run.
- **Safe Extension Uninstallation**: Updates the post-deploy extension uninstallation confirmation in `ext:migrate` to default to `false`, preventing unintended teardown of live extensions during non-interactive runs.
- **Extension Upgrade Prompts & Enforcement**: Ensures extension specifications and version fallbacks are loaded before update checks. Outdated extensions now prompt for confirmation before upgrading in-place, and declining halts migration with instructions to rerun with `--force` to proceed without upgrading.

- Unit tests in `src/commands/functions-kits-install.spec.ts` verifying `.before()` hook experiment gating.
- Unit tests in `src/extensions/migrate.spec.ts` verifying upgrade prompts, `--force` bypass, declined upgrade errors, version fallbacks, and uninstall confirmation defaults.
- `npm run test`
- Manual migration of an out of date storage-resize-images extension.

firebase ext:migrate --package @firebase-function-kits/storage-resize-images@next
firebase ext:migrate --package @firebase-function-kits/storage-resize-images@next --force
…grade is declined

### Description
In `firebase ext:migrate`, when an extension instance has a newer version available, prompt the user with a strongly recommended upgrade prompt, but honor a declined upgrade without requiring `--force`. If declined, log an informative warning indicating that migration continues with the outdated version, then proceed with parameter resolution, scaffolding, and deployment.

### Scenarios Tested
- Declining extension upgrade continues migration with the current instance without calling the update helper.
- Verified warning is logged specifying the instance ID and outdated version.
- Passing `--force` forwards the option to the upgrade confirmation prompt.
- Full mocha test suite passes for `src/extensions/migrate.spec.ts`.

### Sample Commands
firebase ext:migrate
@ajperel
ajperel force-pushed the ajp/fix-ext-migrate-audit branch from a26a54b to 380706c Compare September 10, 2026 22:58
@ajperel
ajperel merged commit 474dbbb into main Sep 11, 2026
99 of 103 checks passed
@ajperel
ajperel deleted the ajp/fix-ext-migrate-audit branch September 11, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants