You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
functions:secrets:prune destroys secret versions that are used outside the current project's secret env vars #11616
firebase-tools: 15.37.0 for secrets labelled firebase-managed=true. With #11067 this also covers secrets labelled firebase-managed=functions, which is the label the CLI has used since v13.6.1.
Platform: macOS
[REQUIRED] Test case
A function that uses a Firebase-managed secret API_KEY in a way other than an env var in the same project, for example a 2nd gen function that mounts it as a volume:
Create a Firebase-managed secret API_KEY with firebase functions:secrets:set API_KEY.
Deploy a function that mounts version 1 as a volume, as above. No function uses version 1 as an env var.
Run firebase functions:secrets:prune.
[REQUIRED] Expected behavior
Version 1 is kept, because a function uses it.
[REQUIRED] Actual behavior
Prune lists API_KEY@1 as unused and offers to destroy it. Once it is destroyed, the function can no longer read /etc/secrets/api_key.
Cause: prune decides a version is in use only if a function in the current project references it as a secret environment variable (pruneSecrets in src/functions/secrets.ts). Other references are not read:
Secret volumes.endpointFromFunction in src/gcp/cloudfunctions.ts and src/gcp/cloudfunctionsv2.ts does not copy secretVolumes, and backend.Endpoint has no field for them.
Functions in other projects. Only the current project's functions are listed. A function in project B that references projects/A/secrets/API_KEY/versions/1 does not stop prune in project A from destroying version 1.
Cloud Run services under the functionsrunapionly or dartfunctions experiments. serviceFromEndpoint in src/gcp/runv2.ts writes secretKeyRef.secret as the short name, and endpointFromService splits it on /, which leaves projectId undefined, so the reference is skipped.
Workaround: run functions:secrets:prune interactively and decline. It prints a functions:secrets:destroy command for each version, so you can run only the ones you know are unused.
I'm working on a fix for the secret volumes part. One addition to the diagnosis: functions:secrets:prune also drops every function not deployed by the Firebase CLI (isFirebaseManaged in src/commands/functions-secrets-prune.ts) before checking usage. So a function deployed with gcloud, like the one in the repro, protects nothing even through env vars. functions:secrets:set already passes all functions to pruneSecrets, so I plan to do the same in prune.
I'm leaving the cross-project case out of the PR. Prune can't list another project's functions, so that probably needs a decision from the team (a warning, or not destroying versions by default) rather than a code fix.
Activity
rarya618 commentedon Dec 2, 2026
I'm working on a fix for the secret volumes part. One addition to the diagnosis:
functions:secrets:prunealso drops every function not deployed by the Firebase CLI (isFirebaseManagedinsrc/commands/functions-secrets-prune.ts) before checking usage. So a function deployed withgcloud, like the one in the repro, protects nothing even through env vars.functions:secrets:setalready passes all functions topruneSecrets, so I plan to do the same in prune.I'm leaving the cross-project case out of the PR. Prune can't list another project's functions, so that probably needs a decision from the team (a warning, or not destroying versions by default) rather than a code fix.