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.

Error about destructuring a property for missing request body -- on a GET

See original GitHub issue

Describe the bug I have an API specification that is valid according to, where I author it. I submitted an issue previously about a pattern that failed, since I was using ‘format’, instead of ‘pattern’

I have fixed that issue, so I no longer get a syntax error, but I’m getting an error when I call my api endpoints now.

The error is: Cannot destructure property 'content' of 'request.openapi.schema.requestBody' as it is null.

The problem is that I have no idea where this is coming from, but it only seems to happen on “GET” requests, where there is no body. As far as I know, that is proper formatting for openapi spec. Am I wrong?

To Reproduce Probably difficult. I might need some direction on where to debug the source code in order to narrow down the issue.

Actual behavior A call to certain API endpoints returns an error response with the exact output

Cannot destructure property 'content' of 'request.openapi.schema.requestBody' as it is null.

Expected behavior Well, if the API is valid (as indicated by, it should not raise an error. Also, requestBody should be empty or null in GET requests.

Examples and context I’m not sure, but a GET request with no defined request body I guess would be a good example.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

lynchmattjcommented, Apr 22, 2021

I figured out my issue, which may or may not be the cause of @kutenai 's problem. It seems that somewhere between 4.9.x and 4.12.x the value of request.openapi.schema.requestBody for GET requests with no body switched from undefined to null and I was checking for undefined when destructuring but not null.

kutenaicommented, Mar 2, 2021

I should mention that if I back up to 4.9.x, it works fine. So far, this fails in the same way on 4.10.x and 4.12.x (latest), so it is consistent.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot destructure property 'userId' of 'req.body' as ...
Here is the solution...yayyy!! No need to install body-parser. try this: app.use(express.json()). And specify it before your routes like:.
Read more >
Destructuring assignment - JavaScript - MDN Web Docs
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from ...
Read more >
Object destructuring best practice in Javascript | by Crunch Tech
This blog post is a short summary of where we started from with our object property access patterns, how we initially started to...
Read more >
TypeScript - Fastify
body inside a GET request will not throw an error (but good luck sending a GET request with a body ). If you...
Read more >
Handling Safe Destructuring in TypeScript - Kamranicus
But alas, TypeScript will throw an error immediately: Property 'results' is missing in type '{}' but required in type 'ResponsePayload'.
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 Post

No results found

github_iconTop Related Hashnode Post

No results found