Skip to content

Firebase CLI fails to resolve service account in multi-project setup #8756

Closed

Description

@Gopinathp

[REQUIRED] Environment details

  • OS: macOS
  • Node.js version: v20.15.1
  • firebase-tools version: 13.11.3

[REQUIRED] Test case

When attempting to deploy Cloud Functions to a staging project in a multi-project setup, the Firebase CLI fails with the following error:

Error: We failed to modify the IAM policy for the project. The functions deployment requires specific roles to be granted to service agents, otherwise the deployment will fail.

i functions: You can either re-run this command as a project owner or manually run the following set of gcloud commands:
i functions: gcloud projects add-iam-policy-binding engage-flow-staging --member=serviceAccount: --role=roles/monitoring.metricWriter
i functions: gcloud projects add-iam-policy-binding engage-flow-staging --member=serviceAccount: --role=roles/cloudtrace.agent
i functions: gcloud projects add-iam-policy-binding engage-flow-staging --member=serviceAccount: --role=roles/logging.logWriter

This error occurs because the Firebase CLI is unable to correctly identify the service account required for deployment, and is instead attempting to modify the IAM policy with an invalid, empty service account.

[REQUIRED] Steps to reproduce

  1. Create a multi-project setup with a default and dev alias in .firebaserc.
  2. Attempt to deploy Cloud Functions to the dev project using firebase deploy --only functions --project dev.

[REQUIRED] Expected behavior

The Firebase CLI should correctly identify the service account and deploy the functions successfully.

[REQUIRED] Actual behavior

The Firebase CLI fails with an "Invalid service account" error.

Troubleshooting Steps Taken

  1. Enabled all necessary APIs: We have enabled the compute.googleapis.com, cloudfunctions.googleapis.com, cloudbuild.googleapis.com, artifactregistry.googleapis.com, cloudscheduler.googleapis.com, run.googleapis.com, eventarc.googleapis.com, pubsub.googleapis.com, storage.googleapis.com, and secretmanager.googleapis.com APIs.
  2. Manually granted all required IAM roles: We have manually granted the roles/monitoring.metricWriter, roles/cloudtrace.agent, and roles/logging.logWriter roles to the [email protected] and service-315566886877@serverless-robot-prod.iam.gserviceaccount.com service accounts.
  3. Updated firebase-tools: We have updated firebase-tools to the latest version.
  4. Corrected the .firebaserc file: We have corrected the .firebaserc file to properly distinguish between the default and dev projects.
  5. Attempted to force the use of a specific service account: We have attempted to force the use of a specific service account by setting the GOOGLE_APPLICATION_CREDENTIALS environment variable.

Despite these efforts, the deployment continues to fail with the same error. This strongly suggests a bug in the Firebase CLI itself.

Activity

  1. DenisovAV commented on Jun 14, 2025

    @DenisovAV

    I am experiencing the same issue. When I try to deploy a new function after enabling GenKit Monitoring, it fails. However, deploying only the old functions works correctly.

  2. DenisovAV commented on Jun 14, 2025

    @DenisovAV

    as workaround I downgraded firebase cli to 13.10.2, it works

  3. EyvindEmilio commented on Jun 14, 2025

    @EyvindEmilio

    Had the same issue. Thanks @DenisovAV. The workaround worked for me, downgrading to [email protected] and Node 20. (I had [email protected])

  4. Linaks commented on Jun 17, 2025

    @Linaks

    Same issue here. Downgraded to fix the issue.

  5. assigned and unassigned on Jun 17, 2025
  6. taeold commented on Jun 18, 2025

    @taeold
    Contributor

    This should be fixed in the next release per #8760

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions