fix(extensions): gate experiments in before hooks, prompt for upgrades, and default uninstall to false in ext:migrate - #11064
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.
ajperel
force-pushed
the
ajp/fix-ext-migrate-audit
branch
3 times, most recently
from
September 10, 2026 00:09
e68352b to
a26a54b
Compare
wandamora
approved these changes
Sep 10, 2026
…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
force-pushed
the
ajp/fix-ext-migrate-audit
branch
from
September 10, 2026 22:58
a26a54b to
380706c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Improves safety and execution flow in
ext:migrateandfunctions:kits:install:.before()hooks onext:migrate(extMigrationFeatures,kits,secretEnvParams) andfunctions:kits:install(kits) so execution fails fast before configuration, IAM, or scaffolding steps run.ext:migrateto default tofalse, preventing unintended teardown of live extensions during non-interactive runs.Scenarios Tested
src/commands/functions-kits-install.spec.tsverifying.before()hook experiment gating.src/extensions/migrate.spec.tsverifying upgrade prompts, declined upgrade warnings, version fallbacks, and uninstall confirmation defaults.npm run testSample Commands
firebase ext:migrate --package @firebase-function-kits/storage-resize-images@next
firebase ext:migrate --package @firebase-function-kits/storage-resize-images@next --force