Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respond with status code 413 if request body is too large #6920

Closed
PatrickG opened this issue Sep 20, 2022 · 1 comment · Fixed by #6936
Closed

Respond with status code 413 if request body is too large #6920

PatrickG opened this issue Sep 20, 2022 · 1 comment · Fixed by #6936
Labels
bug Something isn't working low hanging fruit
Milestone

Comments

@PatrickG
Copy link
Member

PatrickG commented Sep 20, 2022

Describe the bug

Yesterday a few people in the discord tried to help someone who got an error 400 upon requesting an endpoint.
We needed almost an hour to find the problem because he only saw "400 Bad request" and not the message of the thrown Error (idk why).

If the response status code had been 413, we would have found the issue much earlier.

Reproduction

Can not reproduce on stackblitz
https://replit.com/@PehGeh/GreenMutedComma

  • click on "Upload a large file"

Logs

No response

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (8) x64 AMD EPYC 7B12
    Memory: 37.87 GB / 62.80 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.2.0 - /nix/store/q3hh5viyhr3gvfrn6yakbd59gyna0v05-nodejs-18.2.0/bin/node
    Yarn: 1.22.18 - /nix/store/n7d0ibna8751b6kfj6i4fkanbdix8h7a-yarn-1.22.18/bin/yarn
    npm: 8.9.0 - /nix/store/q3hh5viyhr3gvfrn6yakbd59gyna0v05-nodejs-18.2.0/bin/npm

Severity

annoyance

Additional Information

try {
request = await getRequest({
base: origin || get_origin(req.headers),
request: req,
bodySizeLimit: body_size_limit
});
} catch (err) {
res.statusCode = err.status || 400;
res.end(err.reason || 'Invalid request body');
return;
}

It seems like it would be enough to set the status property on the thrown errors to 413.

@theswerd
Copy link

Can this be disabled/edited on specific routes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working low hanging fruit
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants