Deploy Succeeded, Webhook Got 403: Five Misleading Results From One Firebase Functions (2nd Gen) Deploy

The second firebase deploy reported success, and every request to the function got an HTML 403 page from Google. My code never ran. The Cloud Run service behind the function had an empty IAM policy. My runbook gives the reason: the Firebase CLI adds the public invoker when it creates a service, and my successful deploy was recorded as an update.

That was the second of five results on November 2, 2026 that looked like a failed deploy or a broken function and were neither. The function is a 2nd gen HTTPS function (onRequest from firebase-functions/v2/https, Node.js 24, firebase-functions ^7.4.0) that receives RevenueCat's Firebase integration events for a Flutter app of mine and writes the subscriber's entitlements into a Firebase Auth custom claim. It replaced the handler of RevenueCat's Firebase extension. The pull request merged at 02:09 UTC and RevenueCat was pointed at the new function at about 02:35 UTC; the five items below happened in between.

Each item ends with whether documentation describes it.

1. The build succeeded and the deploy failed with an internal error

The command was the ordinary one:

firebase deploy --only functions:revenueCatWebhook --project <project>

It was the first functions deploy in the project, and it enabled the Cloud Run and Eventarc APIs on the way. The build succeeded, and then the deploy failed with this message:

Could not create or update Cloud Run service revenuecatwebhook. The service has encountered an internal error.

gcloud functions describe then showed the function in state FAILED with CloudRunServiceNotFound.

I did not establish why. The Cloud Run troubleshooting page lists a similar sentence for source deployments where the Cloud Build service account lacks permissions, but that case is a failed build, and my build had succeeded. The only circumstance on record is that the same run had just enabled the Cloud Run API, and I have no evidence that this was the cause. What resolved it is also the whole of what I know: the same command, run again, succeeded.

Documented: no. Observed once.

2. The retry succeeded as an update, and the service was closed

The second run ended in success, and it reported the function as updated, not created. A request to the function then returned Google's HTML 403 page. I did not save the body. The Cloud Run troubleshooting page lists two 403 messages for this situation, one of them Your client does not have permission to get URL from this server.

A 403 as HTML, not as JSON from my handler, is the tell: the request was refused by Cloud Run before it reached the container. The service's IAM policy was empty.

The mechanism is in the Firebase CLI's source, in fabricator.ts (the master branch, read on November 13). When the CLI creates a 2nd gen HTTPS function it does this:

const invoker = endpoint.httpsTrigger.invoker || ["public"];
if (!invoker.includes("private")) {
  await this.executor
    .run(() => run.setInvokerCreate(endpoint.project, serviceName, invoker))

When it updates one it does this:

invoker = endpoint.httpsTrigger.invoker === null ? ["public"] : endpoint.httpsTrigger.invoker;
// ...
if (invoker) {

My function sets no invoker option, so on create the default is public, and on update the value is undefined and the CLI leaves IAM alone. As I read it, an update keeps whatever access the service already has, which is nothing when the create never finished. In the create path the invoker step sits after the create call, and a failed create throws before reaching it. My reading is that the first deploy failed before the invoker step and the retry found an existing function resource and took the update path; that is an inference from the source, not something I traced in a debug log.

The fix was one binding on the Cloud Run service, the binding that both the Cloud Run public-access page and the Cloud Run functions IAM page give:

gcloud run services add-iam-policy-binding revenuecatwebhook \
  --region <region> --project <project> \
  --member=allUsers --role=roles/run.invoker

After it, an empty POST answered 401 from my own handler.

Documented: the public-access binding is documented; the create-versus-update difference is in the CLI source, and I did not find it in the Firebase documentation pages I read. Firebase CLI 15.37.0, released on November 19, 2026, lists a fix for this case: "Fixed 2nd gen functions staying uncallable after their first deploy failed, because later deploys never set the invoker." It refers to firebase/firebase-tools#8984, an issue opened in August 2025.

3. The agent was refused the IAM grant

I was working with Claude Code in auto mode. Its permission classifier refused the add-iam-policy-binding command and labeled it [Permission Grant]. I ran the command myself.

There was a way around the refusal: add invoker: "public" to the function options and deploy again. By the update code above, an explicit invoker is applied on update, so that deploy would have made the same grant through a path the classifier had not refused. No such deploy is on record, and on November 27 the function's options still carried no invoker. The note written that day says not to route around the refusal and to hand me the exact command instead.

Documented: I did not read Claude Code's documentation for this; it is what happened in that session.

4. RevenueCat rejected the URL the deploy printed

The deploy printed the function's run.app URL. RevenueCat's Firebase integration settings rejected that URL in the dashboard's Webhook URL field, which my notes from that day call Trigger URL. I did not record the field's error text. It accepted the same function's cloudfunctions.net URL, which this prints:

gcloud functions describe revenueCatWebhook --region <region> --project <project> --format='value(url)'

Both URLs serve the same function.

RevenueCat's current function kit page (read November 13) gives the URL only in the form https://<location>-<project-id>.cloudfunctions.net/... and calls the field Webhook URL. It states no format rule and does not mention run.app. The nearest written statement I found is a user's post in RevenueCat's community forum from February 2023 saying the dashboard "doesn't accept any link outside of the cloudfunctions domain."

Documented: no. The docs show only the accepted form; the rejection is my observation plus one user report.

5. The deploy that worked exited non-zero

Each deploy ended with a warning that the region had no Artifact Registry cleanup policy, and the command exited non-zero although the function was deployed. I did not record the exit code.

The CLI source on master, read on November 13, has the path in prompts.ts. After the functions are deployed, it logs No cleanup policy detected for repositories in <region> and then:

if (options.nonInteractive) {
  throw new FirebaseError(
    `Functions successfully deployed but could not set up cleanup policy in ` +

The message goes on to offer --force or firebase functions:artifacts:setpolicy. So in a non-interactive run without --force, a successful deploy ends in an error by design. Whether my deploys ran non-interactively is not recorded; it is the branch that matches what I saw.

The Firebase documentation describes functions:artifacts:setpolicy, which by default deletes container images older than one day, but the page I read does not mention the warning or the exit status. My deploy log, read again on November 27, still records that no policy is set. --force is not only a cleanup switch: the same file uses that flag to skip other confirmations, including the one before functions are deleted.

Documented: the policy command is; the non-zero exit is only in the source.

The check after a functions deploy

The note I kept says to do three reads before touching RevenueCat: the function's state, the Cloud Run IAM policy, and an empty POST. It records the curl line; the two gcloud lines are how I write the other reads, not a transcript.

# 1. Did the function resource end up healthy? Expect ACTIVE, not FAILED.
gcloud functions describe <function> --region <region> --project <project> --format='value(state)'

# 2. Who may invoke the service? Expect a roles/run.invoker binding with allUsers.
gcloud run services get-iam-policy <service> --region <region> --project <project>

# 3. Does a request reach my code?
curl -sS -X POST -H 'Content-Type: application/json' -d '{}' <function URL>

The third command has three answers worth telling apart in my function. A 401 with {"message":"The webhook token could not be verified with the shared secret."} means the handler ran and rejected an unsigned request, which is the pass. A 500 saying the shared secret is not configured means the secret was never set. An HTML 403 means Cloud Run refused the call and no code of mine is involved.

The exit status of firebase deploy is not on the list. On that day it was non-zero for a deploy that worked (item 5), and the CLI's success message came with a service nobody could call (item 2).

The decision someone could make differently

I made the service public and authenticate inside the function. RevenueCat calls the URL directly and the request carries a token signed with a shared secret; the handler verifies it as an HS256 JWT and answers 401 without writing anything when verification fails. RevenueCat's own kit page says the same of its function: "The function is public, because RevenueCat calls it directly."

The strongest argument against this is that IAM is no longer a layer at all. Anyone can make the function start and run a signature check. Mine is capped at one instance, so by inference a flood of junk requests would compete with real purchase events; I have not tested that. A private service behind an API gateway or an authenticated proxy could put rate limiting in front of the code. That is the general argument and not something I measured: I did not build one, and no source of mine records weighing it. The argument for the simpler shape is that the webhook authenticates with a shared secret, so a gateway in front of it would still be a public endpoint that checks the same secret, plus one more component to deploy. I did not check whether RevenueCat can call an endpoint that requires a Google identity. The Cloud Run page also now recommends disabling the Invoker IAM check over granting allUsers; I used the binding and did not try the alternative.

The second decision is the agent's refusal. No source of mine records weighing this one either, so both sides here are arguments, not my history. The argument for letting the agent run the grant is that it was one role on one service. The argument against is item 3 itself: the same access could be granted by editing one option and deploying, so a rule that blocks one command does not settle who may open a service. The position on record is the note's and the runbook's: the grant needs my approval, the agent hands over the exact command, and I run it.

Limits

This is one Firebase project, one function, and one day, November 2, 2026. The CLI version for the deploys is not recorded, and neither is the gcloud version; a read-only check earlier that day recorded Firebase CLI 15.24.0. The CLI source I quote is master as read on November 13, not necessarily the code that ran. Version 15.37.0 changed this update path; I have not deployed with it. I never saw a clean first create in this project, so "create grants public access" rests on the source and on the note from that day, not on a deploy I watched do it. I did not test --force, --no-invoker-iam-check, an explicit invoker option, or whether RevenueCat still rejects a run.app URL. RevenueCat's documentation, as read on November 13, offers a function kit that replaces the extension. My function is a fork of the extension's handler, and my tracking issue recorded on October 5 that no replacement had been announced. I have not deployed the kit, so I cannot say which of these five it shares.