elastic / elasticsearch-java

Official Elasticsearch Java Client
Apache License 2.0
415 stars 241 forks source link

MissingRequiredPropertyException - Missing required property 'RestoreResponse.snapshot' #423

Open safebees opened 2 years ago

safebees commented 2 years ago

Java API client version

8.4.3 / 8.2.3

Java version

11

Elasticsearch Version

8.2.3

Problem description

In case a client.snapshot().restore is done then always a MissingRequiredPropertyException is thrown with the message Missing required property 'RestoreResponse.snapshot'. The snapshot in the response is checked in constructor of RestoreResponse against requireNonNull.

    RestoreRequest request = new RestoreRequest.Builder().repository("SNAPSHOT_REPO").snapshot(snapshotName)
        .indices(indexNames)
        .waitForCompletion(false)
        .renamePattern("(.+)_index_(.+)")
        .renameReplacement("$1" + indexSuffix)
        .build();
    client.snapshot().restore(request);
co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'RestoreResponse.snapshot'
    at co.elastic.clients.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:76)
    at co.elastic.clients.elasticsearch.snapshot.RestoreResponse.<init>(RestoreResponse.java:57)
    at co.elastic.clients.elasticsearch.snapshot.RestoreResponse.<init>(RestoreResponse.java:50)
    at co.elastic.clients.elasticsearch.snapshot.RestoreResponse$Builder.build(RestoreResponse.java:131)
    at co.elastic.clients.elasticsearch.snapshot.RestoreResponse$Builder.build(RestoreResponse.java:99)
    at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:80)
    at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43)
    at co.elastic.clients.transport.rest_client.RestClientTransport.decodeResponse(RestClientTransport.java:328)
    at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:294)
    at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:147)
    at co.elastic.clients.elasticsearch.snapshot.ElasticsearchSnapshotClient.restore(ElasticsearchSnapshotClient.java:361)
staubt commented 1 year ago

Have the same problem too. I use the low level client for that request but it would be cool it would be possible with the java client.