firebase-tools
firebase-tools copied to clipboard
fix: set public invoker by default on httpsTrigger update
Summary
Fixes https://github.com/firebase/firebase-tools/issues/8984
This PR fixes an issue where HTTPS-triggered functions could become inaccessible after a failed deployment followed by a successful update.
From the original issue:
- A function is initially deployed with a bug that causes the Cloud Run health check to fail
- The deployment partially succeeds, but IAM (invoker) policies are never applied
- After fixing the bug and re-deploying, the CLI performs an update instead of a create
- During this update, IAM policies are not re-applied, leaving the function requiring authentication
- As a result, invoking the function returns 403 Forbidden ("Require authentication")
The root cause is that:
- The create flow sets invoker policies
- The update flow assumes they already exist and skips setting them
- If the initial deployment failed before setting IAM, the function is left without an invoker
Changes
- Ensure
updateV1FunctionandupdateV2Functionset a default invoker (["public"]) when none is specified - Align update behavior with create behavior so IAM policies are always applied
- Prevent functions from remaining inaccessible after recovering from failed deployments
Manual Testing
Reproduced and verified locally:
- Created a new Firebase project and deployed a function with an
httpsTrigger - Introduced a bug causing the function to fail Cloud Run health checks
- Deployed → function entered a broken state (healthcheck failure)
- Fixed the bug
- Re-deployed the function (update flow)
- Observed:
- Before fix:
- Function endpoint returned 403 Forbidden
- Cloud Run showed "Require authentication"
- After fix:
- Function is publicly accessible as expected
- Invoker is correctly set during update
- Before fix:
Tested for:
- GCFv1
- GCFv2
Automated Tests
Added/updated tests in fabricator.spec.ts to verify:
- Default
"public"invoker is applied on update wheninvokeris undefined - Explicit invokers are respected
- Private invokers are not set
- Non-HTTP triggers do not set invokers
These tests ensure:
- Consistency between create and update flows
- Protection against regressions in IAM handling