plaid / plaid-node

Node bindings for Plaid
https://plaid.com/docs
MIT License
525 stars 173 forks source link

Webhook is sending empty request body #581

Open shawnlknight opened 1 year ago

shawnlknight commented 1 year ago

We have an api endpoint that receives transaction webhooks. Specifically, we are checking if the webhook code is INITIAL_UPDATE or HISTORICAL_UPDATE (https://plaid.com/docs/api/products/transactions/#initial_update). This integration was working for about a year. Then, back in February, we updated from "plaid": "10.2.0" to "plaid": "12.3.0".

Nothing else was changed on our side. Now we get an empty request body from the Plaid webhook which has caused issues with our system.

I can see in our dashboard that the webhooks are fired successfully. Here is an example from production:

Screen Shot 2023-06-22 at 3 15 18 PM

We have since tried to downgrade back to "plaid": "10.2.0" but that has not helped the issue.

Can someone please help us figure out what would have changed to where we are now getting empty request bodies?

Thanks!

phoenixy1 commented 1 year ago

@shawnlknight webhooks don't integrate with the client libraries at all so this seems like it is probably not related to the client library upgrade (especially as downgrading didn't fix the problem). Can you file a support ticket including the relevant identifiers (such as item_id) so that the support team can look at the specific webhooks and investigate what's happening?

shawnlknight commented 1 year ago

Thanks for the quick reply @phoenixy1 . I just filed a support ticket through the Plaid dashboard for this issue.

The reason I filed the issue here initially is because we started getting errors about the empty request body the same day we updated our version of plaid-node. Seemed like it could be correlated but obviously does not mean causation.

Thank you.

cgfarmer4 commented 1 year ago

@shawnlknight did this get resolved?

shawnlknight commented 1 year ago

@shawnlknight did this get resolved?

@cgfarmer4 I filed a support ticket through their dashboard and they were very responsive but we were not able to resolve the issue.

cgfarmer4 commented 1 year ago

I see, so you're still receiving the webhooks but the request body is an empty blob? can you forward me the support ticket please?

tiago-sanches-bairesdev commented 1 year ago

@cgfarmer4 The case ID of the support ticket helps?

cgfarmer4 commented 1 year ago

yea thats fine!

tiago-sanches-bairesdev commented 1 year ago

@cgfarmer4 case ID #521412, Shawn gave an example of the piece of code we still using in the webhook endpoint setup, lemme know if you need something else.

cgfarmer4 commented 1 year ago

What version of Next are you all on? Want to try to reproduce on my end.

tiago-sanches-bairesdev commented 1 year ago

@cgfarmer4 We are using Next v13.2.2

tiago-sanches-bairesdev commented 11 months ago

for anyone struggling on that, i searched some stuffs about using nextjs API as a webhook, and I fixed it by adding the micro an using its function buffer, like the code below

  const rawBody = await buffer(req)
  const body = JSON.parse(rawBody.toString())

and this at the end of the code, outside the API function

export const config = {
  api: {
    bodyParser: false,
  },
}
cgfarmer4 commented 11 months ago

Thank you @tiago-sanches-bairesdev for the tip! Ill add this to our ReadMe