14

I'm trying to deploy the firebase function from my local machine

I run the following code:

firebase deploy --only functions  

I'm getting this error.

✔  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (95.46 KB) for uploading
✔  functions: functions folder uploaded successfully
i  functions: creating Node.js 14 function messageNotification(us-central1)...
⚠  functions: failed to create function projects/xxx/locations/us-central1/functions/messageNotification

There isn't any error message. It merely stated that the function failed to be created. Does anyone know why? Thanks in advance!

Edit

I followed what John Hanley suggested and ran

firebase deploy --debug --only functions

and got the following error message

[2021-08-05T01:49:33.605Z] <<< HTTP RESPONSE 400 {"vary":"X-Origin, Referer, Origin,Accept-Encoding","content-type":"application/json; charset=UTF-8","date":"Thu, 05 Aug 2021 01:49:33 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[2021-08-05T01:49:33.605Z] <<< HTTP RESPONSE BODY {"error":{"code":400,"message":"The request has errors","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"event_trigger","description":"Expected value channels/{channelId}/{messageId} to match regular expression [^/]+/[^/]+(/[^/]+/[^/]+)*"}]}]}}

I realized the way I was writing the function was wrong. I was writing it

export const messageNotification = functions.firestore
    .document("channels/{channelId}/{messageId}")...

But I should have written it as shown below instead

export const messageNotification = functions.firestore
    .document("channels/{channelId}/messages/{messageId}")
0

3 Answers 3

36

To debug deployments try two techniques:

Add the command line option --debug"

firebase deploy --debug --only functions

Check the logs for messages:

firebase functions:log
Sign up to request clarification or add additional context in comments.

Comments

3

Make sure when you define the document trigger to use a correct selection of document in the form of

.document("Collection/{documentID}/nestedCollection/{nestedDocumentId}")

Comments

1

For me updating firebase-tools make it works

npm install -g firebase-tools@latest

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.