Skip to content

call ensureInstanceUpToDate in ext:export - #11076

Merged
ajperel merged 2 commits into
mainfrom
vsfan_export_extension_ver_update_2
Sep 12, 2026
Merged

call ensureInstanceUpToDate in ext:export#11076
ajperel merged 2 commits into
mainfrom
vsfan_export_extension_ver_update_2

Conversation

@Berlioz

@Berlioz Berlioz commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Dumb question: is ensureInstanceUpToDate the correct name now that it doesn't, well, ensure that the instance is up to date if the user refuses permission to upgrade?

@Berlioz
Berlioz requested a review from ajperel September 11, 2026 04:36

@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 updates the ext:export command to ensure that the extension instance being exported is up-to-date. It imports and calls ensureInstanceUpToDate with the appropriate options before proceeding with the export. There are no review comments, so I have no additional feedback to provide.

`Extension ${options.instance} is in state ${instance.state}. To export a non-ACTIVE extension, use the --force option.`,
);
}
instance = await ensureInstanceUpToDate(projectId, instance, {

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.

AI says the following. I'm not 100% sure if it's right, but seems easy enough to defensively do this? We really want this removal to work and I'll admit I haven't tested re-deploying after a migration to ensure secrets really weren't deleted.

[Blocking / Safety] Missing Specification Loading (ensureInstanceSpec)getInstance() from the Extensions API does not populate instance.config.source.spec for published extensions. In ensureInstanceUpToDate(), if the instance is already on the latest version or the user declines the upgrade, it returns instance as is without loading spec.Impact:
handleSecretEjection(options, instance)
Calls
secretsNeedingEjection(instance)
which filters instance.config?.source?.spec?.params for secrets. With spec missing, 0 secrets are detected and secret ejection is silently skipped, risking permanent deletion of Secret Manager secrets on subsequent extension uninstall.

functionsEnvFromInstance(instance)
Reads instance.config?.source?.spec?.params and specSystemParams to inject default parameters and FIREBASE_SECRET_REF_* variables. With spec missing, defaults and secret references are omitted from .env.<projectId>.
Recommendation: Follow src/commands/ext-migrate.ts:79-86 by calling ensureInstanceSpec

instance = await ensureInstanceSpec(instance);
if (!instance.config?.source?.spec) {
  throw new FirebaseError(
    `Could not load extension specification for ${clc.bold(options.instance as string)}. Unable to export configuration.`,
  );
}
instance = await ensureInstanceUpToDate(projectId, instance, {
  nonInteractive: options.nonInteractive,
  force: options.force,
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agreed, may as well be paranoid. I don't think that if(throw) does anything, if you look at what ensureInstanceSpec does--it throws if anything goes wrong with the API calls, and then it will always populate a spec with blind reads from the API result even if those reads are undefined.

@ajperel
ajperel force-pushed the vsfan_export_extension_ver_update_2 branch from a2323eb to a35c6e3 Compare September 12, 2026 15:07
@ajperel
ajperel enabled auto-merge (squash) September 12, 2026 15:11
@ajperel
ajperel merged commit b0cb07a into main Sep 12, 2026
50 of 51 checks passed
@ajperel
ajperel deleted the vsfan_export_extension_ver_update_2 branch September 12, 2026 15:17
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