[BUG] Cannot validate webhook
See original GitHub issueBug Report
Describe the bug
There is an error during Webhook validation (the code used to work previously)
This happened in middleware when /webhook
was called
To Reproduce
Steps to reproduce the behavior: 0. You may or may not use the code from my repo (https://github.com/gie3d/nonglinebot)
- Used node line bot sdk and created a
/webhook
that looks like this
app.post('/webhook', line.middleware(config), (req, res) => {
Promise
.all(req.body.events.map(handleEvent))
.then((result) => res.json(result));
});
- Test webhook from Line developers website and check the log
2020-06-15T08:15:23.078099+00:00 heroku[router]: at=info method=POST path="/webhook" host=qline2020.herokuapp.com request_id=5b01db7e-532a-436b-8ba5-c55993174f61 fwd="203.104.156.74" dyno=web.1 connect=1ms service=23ms status=500 bytes=404 protocol=https
2020-06-15T08:15:23.079280+00:00 app[web.1]: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Object
2020-06-15T08:15:23.079323+00:00 app[web.1]: at Hmac.update (internal/crypto/hash.js:82:11)
2020-06-15T08:15:23.079324+00:00 app[web.1]: at Object.validateSignature [as default] (/app/node_modules/@line/bot-sdk/dist/validate-signature.js:14:69)
2020-06-15T08:15:23.079325+00:00 app[web.1]: at _middleware (/app/node_modules/@line/bot-sdk/dist/middleware.js:36:42)
2020-06-15T08:15:23.079326+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5)
The error seems to happen in validate-signature and the type of data seems to be incorrect but I can’t investigate any further.
Expected behavior There should be no error
Environment (please complete the following information):
- OS: Mac OS X 10.15.5
- Node.js 12.6.0
- line-bot-sdk-nodejs 6.8.4
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Cant validate webhook curl error number 60
To solve this problem you have to install ssl chain certificate. You will get full chain certificate by combining your site Certificate (CRT)...
Read more >Sharepoint webhooks - Failed to validate the notification URL
It seems like SharePoint cannot validate the Webhook. Does your Endpoint return the validationtoken within 5 Seconds, i.e.
Read more >Complete Guide to Troubleshooting and Debugging Webhooks
Learn what brings bugs in the process of developing with webhooks, how to tackle these bugs, and tools that can help the troubleshooting...
Read more >Error on Signing Secret Webhook Stripe - WordPress.org
Hi,. Everytime I add the signing secret for Stripe, it seems to return an error in the console log. “Uncaught (in promise) TypeError:...
Read more >Handle errors | Stripe Documentation
If an immediate problem prevents an API call from continuing, the Stripe Ruby ... You're using webhook signature verification and couldn't verify that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @xingoxu @EriecTanijaya, it really was because of the body-parser. My apologise, the code I pushed to heroku was a little different from the git as I didn’t push it to my github repo 😥
Changing from
to
as suggested in https://line.github.io/line-bot-sdk-nodejs/guide/webhook.html#build-a-webhook-server-with-express did solve the problem.
Many thanks 👍
Are you using
bodyParser
before initializing middleware? https://line.github.io/line-bot-sdk-nodejs/guide/webhook.html#build-a-webhook-server-with-express