Skip to content

Failed to decode response when requesting aliases for indices and some do not exist #900

@kved96

Description

@kved96

Java API client version

8.14.3

Java version

17

Elasticsearch Version

8.14.3

Problem description

Running a request for getting indices from aliases throws an UnexpectedJsonEventException when some aliases do not exist, but some do.

co.elastic.clients.transport.TransportException: node: <node name> [es/indices.get_alias] Failed to decode error response, check exception cause for additional details 

Exception cause:

co.elastic.clients.json.UnexpectedJsonEventException: Unexpected JSON event 'START_OBJECT' instead of 'KEY_NAME' 

To reproduce, create an index test_index with an alias test and an index test_index2 without an alias, then using the java client run:

esClient.indices() .getAlias(a -> a.name(List.of("test", "test2")) .allowNoIndices(true) .ignoreUnavailable(true) .expandWildcards(ExpandWildcard.Open)) .result() 

The intended behavior would be to throw the following exception:

co.elastic.clients.elasticsearch._types.ElasticsearchException ErrorResponse: {"error":{"type":"http_status_404","reason":"alias [test] missing"},"status":404} 

Running the same request via curl produces the following:

$ curl https://localhost:9200/_alias/test,test2?pretty { "error" : "alias [test2] missing", "status" : 404, "test_index" : { "aliases" : { "test" : { } } } } 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions