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

Handle additional bodyParser errors #447

Open
matthew-white opened this issue Jan 24, 2022 · 0 comments
Open

Handle additional bodyParser errors #447

matthew-white opened this issue Jan 24, 2022 · 0 comments
Labels

Comments

@matthew-white
Copy link
Member

matthew-white commented Jan 24, 2022

If the size of a JSON request body exceeds the bodyParser limit, then bodyParser will throw an error with a status property of 413. However, Backend will then return a 500 error, not a 413. The error has the message, "Completely unhandled exception: request entity too large". I think it would be ideal for Backend to return a 413 Problem in this case. (See #446 for some more details about this error.)

We already handle bodyParser errors of type entity.parse.failed:

} else if ((error != null) && (error.type === 'entity.parse.failed')) {
// catch body-parser middleware problems. we only ask it to parse JSON, which
// isn't part of OpenRosa, so we can assume a plain JSON response.
defaultErrorWriter(Problem.user.unparseable({ format: 'json', rawLength: error.body.length }), request, response);

Given that, I think we could do something similar with errors of type entity.too.large. It would probably be useful to also take a look at the list of bodyParser errors to see if there are others to account for. (Is there a generic way to handle any bodyParser error?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant