elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
870 stars 24.81k forks source link

RestRequest parameter parsing should not cause 500 error #112604

Closed cbuescher closed 1 month ago

cbuescher commented 1 month ago

Currently, RestRequest can throw IllegalStateExceptions in a few places (e.g. "contentOrSourceParam") that results in 500 errors on the client side and e.g. turn up as warnings in the "rest.suppressed" error log. I believe they should mostly be 400s (Bad Request) instead.

elasticsearchmachine commented 1 month ago

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

cbuescher commented 1 month ago

e.g.

curl -s -XPOST localhost:9200/_search?source=foo

returns

{"error":{"root_cause":[{"type":"illegal_state_exception","reason":"source and source_content_type parameters are required"}],"type":"illegal_state_exception","reason":"source and source_content_type parameters are required"},"status":500}