Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[es/snapshot.restore] Failed to decode Response. Missing required property 'RestoreResponse.snapshot' #891

Open
ACAA06 opened this issue Oct 5, 2024 · 2 comments
Labels
Area: Specification Related to the API spec used to generate client code Category: Bug Something isn't working

Comments

@ACAA06
Copy link

ACAA06 commented Oct 5, 2024

Java API client version

8.14.3

Java version

11

Elasticsearch Version

8.15

Problem description

Logs:
co.elastic.clients.transport.TransportException: node: https://************:9200/, status: 200, [es/snapshot.restore] Failed to decode response

Java code which creates the snapshot:

        RestoreRequest.Builder restoreRequestBuilder = new RestoreRequest.Builder();
        restoreRequestBuilder.repository(repoName);
        restoreRequestBuilder.snapshot(snapshot);
        restoreRequestBuilder.indices(indices);
        
        elasticsearchClient.snapshot().restore(restoreRequestBuilder.build());

The snapshot is successfully created on Elasticsearch, but the code fails to parse the response from the server, which simply returns:

        {
          "accepted": true
        }

But the sdk requires a non-null snapshot:

        private RestoreResponse(Builder builder) {
              this.snapshot = (SnapshotRestore) ApiTypeHelper.requireNonNull(builder.snapshot, this, "snapshot");
          }

Can someone help me with this please? Am i doing something wrong here?

@l-trotta l-trotta added Area: Specification Related to the API spec used to generate client code Category: Bug Something isn't working labels Oct 7, 2024
@l-trotta
Copy link
Contributor

l-trotta commented Oct 7, 2024

Hello, thanks for reporting this! What you're doing seems correct, so it looks like the server returns something that we had not considered in the API specification used to produce the Java code; we'll fix the specification and regenerate the client.

In the meantime, what you can do as a workaround is disable the check just for that specific call, by performing it inside a try block configured like this:

try (ApiTypeHelper.DisabledChecksHandle h = ApiTypeHelper.DANGEROUS_disableRequiredPropertiesCheck(true)) {
 elasticsearchClient.snapshot()
    .restore(r -> r
        .indices(indices)
        .repository(repository)
        .snapshot(snapshot));
}

As the method name says, it's dangerous to use because it basically ignores every check the client normally performs on non nullable properties, so only use it to make the call work (all fields in the response will be null, but in this case you don't need it).

I'll update this when the fix becomes available in the next patch, so that you can just use the API normally.

@ACAA06
Copy link
Author

ACAA06 commented Oct 8, 2024

Hi, Thank you for your response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Specification Related to the API spec used to generate client code Category: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants