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

Return 400 when handling invalid JSON #49552

Merged

Conversation

pugnascotia
Copy link
Contributor

Closes #49428. The code that works out an HTTP code for an exception didn't consider the JsonParseException case, meant that an invalid JSON request could result in a 500 Internal Server Error. Now it returns 400 Bad Request.

@pugnascotia pugnascotia added >bug :Core/Infra/REST API REST infrastructure and utilities v8.0.0 labels Nov 25, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/REST API)

Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Given that this is a bug fix shouldn't we target to 7.x as well?

@pugnascotia
Copy link
Contributor Author

Oops, yes, that's an oversight on my part.

@pugnascotia
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/packaging-sample-matrix due to transient error

@pugnascotia pugnascotia merged commit fc33ee4 into elastic:master Nov 25, 2019
@pugnascotia pugnascotia deleted the 49428-invalid-json-400-response branch November 25, 2019 17:15
pugnascotia added a commit to pugnascotia/elasticsearch that referenced this pull request Nov 25, 2019
Closes elastic#49428. The code that works out an HTTP code for an exception didn't
consider the JsonParseException case, meant that an invalid JSON request could
result in a 500 Internal Server Error. Now it returns 400 Bad Request.
pugnascotia added a commit that referenced this pull request Nov 26, 2019
Backport of #49552.

Closes #49428. The code that works out an HTTP code for an exception didn't
consider the JsonParseException case, meant that an invalid JSON request could
result in a 500 Internal Server Error. Now it returns 400 Bad Request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid JSON request bodies result in 500 response
4 participants