question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle body when it's already parsed

See original GitHub issue

Moved from #5

The problem is that we really do not know how req.body has been parsed by just checking its type (e.g. Firebase Cloud Functions). It’s straight forward when its type is string, but things go difficult when it’s an object. Calling .toString() cannot be a silver bullet as we do not know how it’s implemented. If it results in a different string from the original request body, the validation process will silently fail which I do not want to happen.

I will first make it work with a string and a buffer, and look into how an object can be handled. Any idea is welcomed.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hatashirocommented, May 22, 2017

After internal review, we decide to reject this PR as it’s not very safe to support this kind of option. There cannot be a silver-bullet function to revert an object into the original body buffer.

Rather than this, the case should be handled by using the validateSignature() function directly.

0reactions
hatashirocommented, Nov 12, 2018

Great news! Let’s do this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js - Handle body-parser invalid JSON error
When a valid input like { "foo": "bar" } is received everything works fine and I can access the parsed object with req.body...
Read more >
Express body-parser middleware
Returns middleware that parses all bodies as a Buffer and only looks at requests where the Content-Type header matches the type option. This...
Read more >
Read and parse POST/PATCH/PUT request JSON or form ...
Read and parse POST/PATCH/PUT request JSON or form body with Express and no dependencies. When asked to handle data in a request body, ......
Read more >
Express JS— body-parser and why may not need it
Node/Express​​ This piece of middleware was called body-parser and used to not be part of the Express framework. The good news is that...
Read more >
Creating a REST API with Node.js - YouTube
Let's parse our request body, so that our RESTful API can receive and use data. And handle CORS to allow other clients to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found