Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request fixes an issue where function deployments incorrectly reported success when the managed service account for declarative security could not be deleted. The deleteServiceAccount function in src/gcp/iam.ts was updated to only ignore 404 errors and propagate other errors, such as 403 Permission Denied. Relevant unit tests were added to verify this behavior, and the changelog was updated. There are no review comments to evaluate.
deleteServiceAccount passed resolveOnHTTPError, so a 403 was returned instead of thrown and removeOldRoles reported a successful opt-out while the managed service account was left behind. Ignore a 404 and throw on any other error. Fixes firebase#11551
Ultranmus
force-pushed
the
fix/delete-managed-sa-error
branch
from
December 3, 2026 13:30
18bf39e to
37f6766
Compare
This branch has not been deployed
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
Fixes #11551. Part of #11564.
When a codebase opts out of declarative security,
removeOldRolesdeletes the managed service account and has acatchthat turns a failure into "Failed to delete managed service account ... Please ask an IAM administrator to delete it manually." Thatcatchnever ran, becausedeleteServiceAccountpassedresolveOnHTTPError: true: a 403 was returned instead of thrown, and the deploy finished with "Deploy complete!" while the account and its roles stayed behind.deleteServiceAccountnow ignores a 404 (the account is already gone, same as before) and throws on any other error.The other callers are fine with this:
fabricator.ts(role grant failure, 100% deploy failure) already catch and log the error.Scenarios Tested
iam.spec.tstest: a 403 from the delete is thrown. It fails without the fix. The existing "404 doesn't throw" test still passes.fabricator.spec.tstest:removeOldRolesfails with the "Failed to delete managed service account" error when the delete fails.npm run mocha: 6142 passing. The "should output the date in the correct format" test also fails onmain, and an auth emulator test that failed in the full run passes on its own.tsc, prettier, and eslint (no new warnings).Sample Commands
firebase deploy --only functionsafter removingrequiresRole, as a deployer withoutiam.serviceAccounts.delete.