Failed to create function project when deploying firebase cloud function

1,612

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
Share:
1,612
scott lee
Author by

scott lee

Updated on December 31, 2022

Comments

  • scott lee
    scott lee over 1 year

    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}")
    
    • John Hanley
      John Hanley over 2 years
      Do you see anything in the logs?**firebase functions:log** 2) Try firebase deploy --debug --only functions
    • scott lee
      scott lee over 2 years
      Hey @JohnHanley, I ran that code and managed to troubleshoot the problem. I have edited my question as shown above. You might want to move your comment to a suggested answer if you want. I will mark it as the correct answer. Thanks!
  • Mattwmaster58
    Mattwmaster58 about 2 years
    Thanks, this helped me figure out a subtle formatting error in my document's path