plaid-node icon indicating copy to clipboard operation
plaid-node copied to clipboard

Webhook is sending empty request body

Open shawnlknight opened this issue 2 years ago • 12 comments

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!

shawnlknight avatar Jun 22 '23 21:06 shawnlknight

@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?

phoenixy1 avatar Jun 22 '23 22:06 phoenixy1

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.

shawnlknight avatar Jun 23 '23 13:06 shawnlknight

@shawnlknight did this get resolved?

cgfarmer4 avatar Sep 25 '23 17:09 cgfarmer4

@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.

shawnlknight avatar Sep 25 '23 17:09 shawnlknight

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?

cgfarmer4 avatar Sep 25 '23 18:09 cgfarmer4

@cgfarmer4 The case ID of the support ticket helps?

tiago-sanches-bairesdev avatar Sep 25 '23 18:09 tiago-sanches-bairesdev

yea thats fine!

cgfarmer4 avatar Sep 25 '23 19:09 cgfarmer4

@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.

tiago-sanches-bairesdev avatar Sep 25 '23 19:09 tiago-sanches-bairesdev

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

cgfarmer4 avatar Sep 28 '23 18:09 cgfarmer4

@cgfarmer4 We are using Next v13.2.2

tiago-sanches-bairesdev avatar Sep 28 '23 18:09 tiago-sanches-bairesdev

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,
  },
}

tiago-sanches-bairesdev avatar Dec 14 '23 18:12 tiago-sanches-bairesdev

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

cgfarmer4 avatar Dec 14 '23 21:12 cgfarmer4