Firebase cloud function deploy error - HTTP Error: 400, Invalid JSON payload received

Viewed 941

I am using the stripe-firestore-invoices cloud function in my project. I needed to customize it to satisfy my use case, so instead of installing the extension, I had downloaded the source code and tried deploying. However, the function to send the invoice (it's a firestore handler function) doesn't get deployed and throws the following error:

!  functions: failed to create function devInvoice-sendInvoice
HTTP Error: 400, Invalid JSON payload received. Unknown name "children" at 'function': Cannot find field.
Invalid JSON payload received. Unknown name "exit" at 'function': Cannot find field.
Invalid JSON payload received. Unknown name "message" at 'function': Cannot find field.

I am running the latest version of firebase-tools: v8.9.0

I tried updating the dependencies to their latest versions:

firebase-functions: v3.11.0
firebase-admin: v9.1.1
stripe: v8.89.0

Still the same error persists.

1 Answers

Funny - I came across this because I was doing exactly the same thing (only in my case, using firestore-stripe-subscriptions).

If you run the following, it provides a clue to the error message:

firebase deploy --only functions --debug

The issue is a missing trigger.

Oddly, I found that the root cause appears to be an error in the Stripe source (at least that's what appeared to be blocking my deployment...)

Changing the https handler from:

functions.handler.https.onRequest

to

functions.https.onRequest

Resolved the issue for me.

Related