-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Invalid JSON request bodies result in 500 response #49428
Comments
Pinging @elastic/es-core-infra (:Core/Infra/REST API) |
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.
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.
Clients don't retry 500 See: https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/fail-over.html And elasticsearch/client/test/src/main/java/org/elasticsearch/client/RestClientTestUtil.java Line 39 in 237650e
Great fix though thanks @pugnascotia ! |
Some clients do, for example, Beats: https://github.com/elastic/beats/blob/ee5a4e73a98fbf63307cd5d7f6cfcf196bb15bd3/libbeat/outputs/elasticsearch/client.go#L522-L524 |
Elasticsearch version: v7.3.1
OS version: Linux 4.4.0-1098-aws
JVM: OpenJDK 1.8.0_201 / 25.201-b09
Current behaviour:
If I execute a search with an invalid JSON request body, e.g. missing a double-quote:
Then ES rejects the query with a 500, which indicates a server-side problem.
Expected behaviour:
The server should respond with "400 Bad Request", to indicate a client problem.
Impact:
The 500 is problematic because it indicates to clients that they can retry the request, but of course it will always fail. See also #48308, which concerns the Bulk API.
The text was updated successfully, but these errors were encountered: