elasticsearch-java icon indicating copy to clipboard operation
elasticsearch-java copied to clipboard

[es/snapshot.get] Client does not support Azure Snapshot Repository. Missing required property 'GetSnapshotRequest.repository'

Open synox opened this issue 3 years ago • 1 comments

Java API client version

7.16.2

Java version

java 11.0.14 2022-01-18 LTS

Elasticsearch Version

7.16.2

Problem description

The client can not parse the following response, which is an azure blob store configuration.

{
  "found-snapshots": {
    "type": "azure",
    "uuid": "Ujhg4G83Sve5_cH76iUssg",
    "settings": {
      "container": "a1a8dd8256d81eae1a70549ea66e45a",
      "client": "elastic-internal-e757c8",
      "base_path": "snapshots/5f160fc1800c5a716d26b7fbb3c63e40",
      "container_name": "0f27d258ed85c6170bf9cea6bbffa1e",
      "use_for_peer_recovery": "true"
    }
  }
}

Error

MissingRequiredPropertyException: Missing required property 'GetSnapshotRequest.repository'

	at co.elastic.clients.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:76)
	at co.elastic.clients.elasticsearch.snapshot.GetSnapshotRequest.<init>(GetSnapshotRequest.java:91)
	at co.elastic.clients.elasticsearch.snapshot.GetSnapshotRequest.<init>(GetSnapshotRequest.java:59)
	at co.elastic.clients.elasticsearch.snapshot.GetSnapshotRequest$Builder.build(GetSnapshotRequest.java:356)
	at co.elastic.clients.elasticsearch.snapshot.GetSnapshotRequest$Builder.build(GetSnapshotRequest.java:199)
	at co.elastic.clients.elasticsearch.snapshot.ElasticsearchSnapshotClient.get(ElasticsearchSnapshotClient.java:296)

Code:

            GetSnapshotResponse snapshotRepositories = client
                    .snapshot()
                    .get(b -> b);

in the spec the Field GetSnapshotRequest.repository is mandatory.

synox avatar Mar 17 '22 21:03 synox

Support for Azure repositories is indeed missing. It's an issue in the upstream API specification which is fixed in https://github.com/elastic/elasticsearch-specification/pull/1771

The fix will be included in the Java client 7.17.6 & 8.4.0.

That being said, client.snapshot().get() is used to retrieve snapshot information and has two required properties, repository and snapshot (which can be * or _all to retrieve all snapshots). To retrieve snapshot repository information, you should use client.snapshot().getRepository().

swallez avatar Jun 27 '22 15:06 swallez