elastic/elasticsearch-java

ElasticsearchAsyncSearchClient: Error Responses can't be deserialized

str8y opened this issue · 2 comments

str8y commented

Java API client version

8.7.1

Java version

17

Elasticsearch Version

8.7.1

Problem description

The ElasticsearchAsyncSearchClient expects ErrorResponse in case of an issue.
ErrorResponse has status as a required property but the Elasticsearch error response for asyncSearch requests doesn't have a status -> ErrorResponse can't be deserialized. Instead the Endpoint's ResponseType is returned (if this can be deserialized) and the actual issue is suppressed.

Hello, thanks for reporting this! I tried to reproduce this, but I'm getting the same errors both with the synchronous client and the asynchronous client. If this is still an issue, could you provide an example of this behaviour? Thank you.

Which version did you test? I still see issues (different ones, as for 8.7.1) with version 8.12.2.
The response from es contains more than just error or status, which could be read by co.elastic.clients.transport.endpoints.EndpointBase#errorDeserializer

{ "is_partial": true, "is_running": false, "start_time_in_millis": 1714037648836, "expiration_time_in_millis": 1714037707836, "completion_time_in_millis": 1714037648838, "response": { "took": 2, "timed_out": false, "terminated_early": false, "num_reduce_phases": 0, "_shards": { "total": 3, "successful": 0, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 0, "relation": "gte" }, "max_score": null, "hits": [] } }, "error": { "type": "status_exception", "reason": "error while executing search", "caused_by": { "type": "search_phase_execution_exception", "reason": "", "phase": "fetch", "grouped": true, "failed_shards": [], "caused_by": { "type": "too_many_buckets_exception", "reason": "Trying to create too many buckets. Must be less than or equal to: [5] but this number of buckets was exceeded. This limit can be set by changing the [search.max_buckets] cluster level setting.", "max_buckets": 5 } } } }