googlearchive / cloud-functions-emulator

A local emulator for deploying, running, and debugging Google Cloud Functions.
https://github.com/GoogleCloudPlatform/cloud-functions-emulator/wiki
Apache License 2.0
827 stars 115 forks source link

failed to deploy firebase function,error code: 405 #182

Open Aditya21196 opened 6 years ago

Aditya21196 commented 6 years ago

I was deploying functions yesterday but when I closed my node project and reopened it, I was greeted by this error:

Failed to configure Firebase Realtime Database trigger: unknown error, HTTP code 405

Functions deploy had errors. To continue deploying other features (such as database), run: firebase deploy --except functions

Error: Functions did not deploy properly.

I tried using the suggested function but it didn't work either. I tried searching online for solutions but found none.

pavelpuchok commented 6 years ago

I was experienced the same issue today. I found problem which caused this in my function code. I make mistake in ref path and use js template string style for path variable. So it was exports.myFunc = functions.database.ref('/my/path/${uid}') instead exports.myFunc = functions.database.ref('/my/path/{uid}').

prazjain commented 6 years ago

This is how I resolved it: this is how i used it : functions.database.ref('/my/path/${uid}') expected : functions.database.ref(/my/path/{uid})

1) Changed ' to ` 2) Removed $ before variable name

This issue can be closed.

Caemostajo commented 6 years ago

I have the same error, this issue is not closed,

your instructions are not clear: Changed ' to ` (what? can you be more clear like x => o (x changed to o) Removed $ before variable name (where, put before and after)

thx!

i´m not sure but i think cloud functions is very tricky, an error always pop up!

SebasG22 commented 6 years ago

Please check your code, Firebase cannot identify uid variable using '' ( Normal String). If you are trying to assign a variable value to string, you must use {} without ES6 Multiline String(${variableName}) Error - Not ${variableName}

exports.myFunc = functions.database.ref('/my/path/${uid}')

Solution - Use only {variableName}

exports.myFunc = functions.database.ref('/my/path/{uid}')

But in this case you are trying to access to dynamic uid you must use normal string with {}, because firebase will recognize {dynamicUID} as the id following the path.

Example:

Firebase Structure Users/1234/likes/likeId Firebase ref to dynamic id on likes Users/{userId}/likes/{likeId}

This issue can be closed.

joelgetaction commented 6 years ago

I had the same issue. It's because I had:

// Note the errant $
fooFunction: db.ref("posts/${userId}").onCreate(...)

instead of

// Note the (correct) lack of $
fooFunction: db.ref("posts/{userId}").onCreate(...)

Firebase, this 405 error is very cryptic, any chance you could improve this error reporting so future users have it a bit easier? :-)