[Python] What's wrong with my Python Firebase Cloud Function?

Discussão em 'Python' iniciado por Stack, Julho 13, 2025.

  1. Stack

    Stack Membro Participativo

    When trying to deploy the function below I get the error:


    Build failed with status: FAILURE. Could not build the function due to a missing permission on the build service account. If you didn't revoke that permission explicitly, this could be caused by a change in the organization policies. Please refer to the following documentation for more details and resolution: https://cloud.google.com/functions/docs/troubleshooting#build-service-account
    ​

    Actually, I can see the function on Firebase Console, but it says "unknown trigger".

    I can also see the following error messages on Google Cloud Console:


    Build failed with status: FAILURE. Could not build the function due to a missing permission on the build service account. If you didn't revoke that permission explicitly, this could be caused by a change in the organization policies. Please refer to the following documentation for more details and resolution: https://cloud.google.com/functions/docs/troubleshooting#build-service-account You can also view the logs at...


    Eventarc trigger projects/myproject/locations/nam5/triggers/sendNotification-xxxxxx for the function was not found. The function may not work correctly. Please redeploy.


    Cloud Run service projects/myproject/locations/us-central1/services/sendNotification for the function was not found. The function will not work correctly. Please redeploy.
    ​

    import firebase_admin
    from firebase_functions import https_fn, firestore_fn
    from firebase_admin import initialize_app, credentials, firestore, messaging
    import google.cloud.firestore

    app = initialize_app()

    @firestore_fn.on_document_created(document = "users/{userId}/invites/{inviteId}")
    def sendNotification(event: firestore_fn.Event[firestore_fn.DocumentSnapshot | None],) -> None :
    if event.data is None:
    return
    try:
    userId = event.params["userId"]
    db = firestore.client()
    user_ref = db.collection("users").doc(userId)
    user_data = user_ref.get().to_dict
    tokenFCM = user_data.get("tokenFCM")
    print(f"user token: {tokenFCM}")
    except KeyError:
    return


    I'm kinda copying and pasting from Cloud Functions documentation but still it's not working.

    I'm writing more to implement the notification sending, but for now Im testing if the firestore trigger is working (and it's not :/ ).

    Continue reading...

Compartilhe esta Página