Skip to content

Deprecation warnings break the high-level client in strict mode #37090

Closed
@javanna

Description

@javanna

When the high-level client uses a low-level client that fails on deprecation warnings, that breaks the high-level client quite badly. The low-level client throws a ResponseException which is caught by the high-level client which tries to parse the response body as if it was an error, although it most likely was not. Instead of signaling the deprecation warnings clearly, the high-level client ends up breaking with:

   > Throwable #1: ElasticsearchStatusException[Unable to parse response body]; nested: ResponseException[method [PUT], host [http://[::1]:33451], URI [/dev_product/product/test.com%2F48923AQ3?timeout=1m], status line [HTTP/1.1 201 Created]
   > Warnings: [[types removal] Specifying types in document index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, or /{index}/_create/{id}).]
   > ¿f_indexkdev_producte_typegproductc_idqtest.com/48923AQ3h_version�fresultgcreatedg_shards¿etotal�jsuccessful�ffailedÿg_seq_nom_primary_term�ÿ]; nested: ResponseException[method [PUT], host [http://[::1]:33451], URI [/dev_product/product/test.com%2F48923AQ3?timeout=1m], status line [HTTP/1.1 201 Created]
   > Warnings: [[types removal] Specifying types in document index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, or /{index}/_create/{id}).]
   > ¿f_indexkdev_producte_typegproductc_idqtest.com/48923AQ3h_version�fresultgcreatedg_shards¿etotal�jsuccessful�ffailedÿg_seq_nom_primary_term�ÿ];
   >    at __randomizedtesting.SeedInfo.seed([CE50F89A4C8ADC37:26EE63FC8DB7EE6D]:0)
   >    at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1681)
   >    at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1442)
   >    at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1399)
   >    at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1369)
   >    at org.elasticsearch.client.RestHighLevelClient.index(RestHighLevelClient.java:817)
   >    at org.elasticsearch.client.CrudIT.testWeirdId(CrudIT.java:1379)
   >    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   >    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   >    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   >    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
   >    at java.base/java.lang.Thread.run(Thread.java:844)
   >    Suppressed: ParsingException[Failed to parse object: expecting field with name [error] but found [_index]]
   >            at org.elasticsearch.common.xcontent.XContentParserUtils.ensureFieldName(XContentParserUtils.java:50)
   >            at org.elasticsearch.ElasticsearchException.failureFromXContent(ElasticsearchException.java:587)
   >            at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:169)
   >            at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1701)
   >            at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1677)
   >            ... 41 more
   > Caused by: org.elasticsearch.client.ResponseException: method [PUT], host [http://[::1]:33451], URI [/dev_product/product/test.com%2F48923AQ3?timeout=1m], status line [HTTP/1.1 201 Created]
   > Warnings: [[types removal] Specifying types in document index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, or /{index}/_create/{id}).]
   > ¿f_indexkdev_producte_typegproductc_idqtest.com/48923AQ3h_version�fresultgcreatedg_shards¿etotal�jsuccessful�ffailedÿg_seq_nom_primary_term�ÿ
   >    at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:690)
   >    at org.elasticsearch.client.RestClient.performRequest(RestClient.java:218)
   >    at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1429)
   >    ... 40 more
   > Caused by: org.elasticsearch.client.ResponseException: method [PUT], host [http://[::1]:33451], URI [/dev_product/product/test.com%2F48923AQ3?timeout=1m], status line [HTTP/1.1 201 Created]
   > Warnings: [[types removal] Specifying types in document index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, or /{index}/_create/{id}).]
   > ¿f_indexkdev_producte_typegproductc_idqtest.com/48923AQ3h_version�fresultgcreatedg_shards¿etotal�jsuccessful�ffailedÿg_seq_nom_primary_term�ÿ
   >    at org.elasticsearch.client.RestClient$1.completed(RestClient.java:304)
   >    at org.elasticsearch.client.RestClient$1.completed(RestClient.java:294)
   >    at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:119)
   >    at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:177)
   >    at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:436)
   >    at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:326)
   >    at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:265)
   >    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)
   >    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)
   >    at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:114)
   >    at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)
   >    at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)
   >    at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
   >    at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
   >    at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
   >    at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588)
   >    ... 1 more

The cause of the failure does contain the deprecation warnings, but it is not so obvious that they did cause the exception to be thrown. The problem here is that a ResponseException gets thrown based on a response that returned OK status code, and no additional exception message is provided to signal what the problem was. The response itself does not necessarily tell the reason of the failure. That same response would not cause any exception with strict deprecation disabled. I believe we should use a different exception for deprecation warnings.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions