Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Functions for Firebase error: "400, Change of function trigger type or event provider is not allowed"

When I run firebase deploy I get this error message:

functions: HTTP Error: 400, Change of function trigger type or event provider is not allowed
like image 422
Thomas David Kehoe Avatar asked Oct 02 '17 17:10

Thomas David Kehoe


3 Answers

TL;DR

firebase functions:delete yourFunction // this can be done via the Firebase Console as well
firebase deploy

Explanation

Basically, Cloud Functions expects the same trigger for every function all the time, i.e. once it is created it has to stick to its original trigger because every function name is connected to a specific trigger. The trigger can therefore only be changed by deleting the function first and then creating it again with a different trigger.

This can now be done easily by using the functions:delete command:

firebase functions:delete yourFunction

The documentation features more advanced use cases as well.

Old solution

Solution of this is basically commenting or cutting out your function and then saving the Functions file and deploying. The function will get deleted in Firebase, but after that you can insert/uncomment your function and it will deploy just fine again. This error occurs when you take a function and change the type of trigger that it uses, i.e. HTTP, database or authentication.

Firstly cut it out

/* exports.yourFunction = someTrigger... */

And then, after deploying ("firebase deploy") replace your trigger

exports.yourFunction = anotherTrigger...
like image 152
creativecreatorormaybenot Avatar answered Nov 11 '22 15:11

creativecreatorormaybenot


For those who stumble upon this in the future, the Cloud Functions console now offers a delete button. screenshot of the right hand side's "more" options

like image 32
Adrian Murray Avatar answered Nov 11 '22 15:11

Adrian Murray


You can also go to the Cloud Functions panel in the Google Cloud Platform console and delete your function from there. After that you can upload the function normally from firebase CLI. Not sure why they don't have a delete function option in the firebase console.

like image 1
Ricky Gomes Avatar answered Nov 11 '22 14:11

Ricky Gomes