fix(functions): clean up managed service accounts on declarative opt-out during filtered multi-codebase deploys - #11052
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a fix to clean up managed service accounts when opting out of declarative security alongside a filtered codebase deploy. It extracts the logic to check if a codebase is partially filtered into a helper function isCodebasePartiallyFiltered in functionsDeployHelper.ts, which is then utilized in both prepare.ts and planner.ts. Unit tests have been added to verify this helper function and the updated planner behavior. There are no review comments, and I have no additional feedback to provide.
Berlioz
approved these changes
Sep 9, 2026
…out during filtered multi-codebase deploys When deploying multiple codebases where one codebase opts out of declarative security while another codebase uses a partial function filter (e.g. `--only functions:codebaseA,functions:codebaseB:funcB`), `prepare.ts` scoped its partial-filter check to `codebaseA`, discovering the unenrollment and updating functions to remove declarative labels and IAM bindings. However, `planner.ts` checked function filters globally across all codebases. This marked `codebaseA` as partially filtered, suppressing deletion of the managed service account and permanently orphaning it in GCP IAM. This change: - Extracts `isCodebasePartiallyFiltered(codebase, filters)` into `functionsDeployHelper.ts` to share consistent codebase-scoped partial-filter evaluation across discovery (`prepare.ts`) and planning (`planner.ts`). - Updates the deployment planner to scope partial-filter checks to the target codebase, ensuring the managed service account is deleted during opt-out unless that specific codebase is partially filtered. - **Unit tests**: - `src/deploy/functions/functionsDeployHelper.spec.ts`: Added tests for `isCodebasePartiallyFiltered` covering undefined/empty filters, full codebase filters, foreign codebase partial filters, matching partial filters, and wildcard partial filters. - `src/deploy/functions/release/planner.spec.ts`: Added regression test verifying that opting out of a whole codebase alongside a filtered codebase deploy schedules the managed service account for deletion. - `npm test` ```bash firebase deploy --only functions:codebaseA,functions:codebaseB:funcB firebase deploy --only functions:codebaseA ```
ajperel
force-pushed
the
ajp/fix-declartive-partial-deployment
branch
from
September 9, 2026 23:49
fe188b7 to
433a491
Compare
ajperel
enabled auto-merge (squash)
September 9, 2026 23:50
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
When deploying multiple codebases where one codebase opts out of declarative security while another codebase uses a partial function filter (e.g.
--only functions:codebaseA,functions:codebaseB:funcB),prepare.tsscoped its partial-filter check tocodebaseA, discovering the unenrollment and updating functions to remove declarative labels and IAM bindings.However,
planner.tschecked function filters globally across all codebases. This markedcodebaseAas partially filtered, suppressing deletion of the managed service account and permanently orphaning it in GCP IAM.This change:
isCodebasePartiallyFiltered(codebase, filters)intofunctionsDeployHelper.tsto share consistent codebase-scoped partial-filter evaluation across discovery (prepare.ts) and planning (planner.ts).Scenarios Tested
src/deploy/functions/functionsDeployHelper.spec.ts: Added tests forisCodebasePartiallyFilteredcovering undefined/empty filters, full codebase filters, foreign codebase partial filters, matching partial filters, and wildcard partial filters.src/deploy/functions/release/planner.spec.ts: Added regression test verifying that opting out of a whole codebase alongside a filtered codebase deploy schedules the managed service account for deletion.npm testSample Commands