Home > Software engineering >  Firebase deploy failed even without changing the function from onCallable to onRequest
Firebase deploy failed even without changing the function from onCallable to onRequest

Time:03-17

Error: [functionName(us-central1)] Changing from a callable function to an HTTPS function is not allowed. Please delete your function and create a new one instead.

Any advice and insight is appreciated.

CodePudding user response:

Which version of Firebase CLI (firebase --version) are you using? Last night I updated firebase-tools package to 10.3.0 and functions deployment started giving me the error you mention. I downgraded to 10.2.2 and functions deployment started working as before.

Update: Firebase team confirmed there is an issue with 10.3.0 firebase-tools. They are working on a fix: https://github.com/firebase/firebase-tools/issues/4307

CodePudding user response:

Solution 01:
I think the main problem lies inside whether you are using a valid way to use .env file. Since I just recently have this kind of error. If you do use the .env file inside the structure of your folder, then

  • You need to declare the path to .env file in all files which uses process.env.VARIABLE_NAME. Example way is like this: require("dotenv").config({path: "../.env"});
  • After that try to delete all existing Cloud Functions in Google Cloud Console
  • Try deploy again: firebase deploy --only functions

I added a path to the .env file, since I checked Firebase Cloud Function Logs and it gave me error for all Cloud Functions which uses process.env.VARIABLE_NAME. This .env file must be located inside the root project and placed inside folder functions/. Give it a try. Hope it works.

Solution no. 2:
You should check if there is a variable or function which doesn't give return value, like example below:

const key = async () => {
  const response = await pk.accessSecret("PRIVATEKEY");
  return response;
};


I forgot to add a return value from the variable const key. Therefore I get so many errors like you do in all of my functions. And that errors cause firebase cli to state"

Changing from a callable function to an HTTPS function is not allowed. Please delete your function and create a new one instead.

  • Related