opensearch-java: [BUG] org.opensearch.client.util.MissingRequiredPropertyException: Missing required property 'OpenSearchVersionInfo.distribution'
What is the bug?
Earlier today, I upgraded my AWS OpenSearch cluster from version 2.5 to 2.7, and now I’m seeing the following exception when fetching the cluster information on startup:
Caused by: org.opensearch.client.util.MissingRequiredPropertyException: Missing required property 'OpenSearchVersionInfo.distribution'
at org.opensearch.client.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:88) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.opensearch._types.OpenSearchVersionInfo.<init>(OpenSearchVersionInfo.java:82) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.opensearch._types.OpenSearchVersionInfo$Builder.build(OpenSearchVersionInfo.java:324) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.opensearch._types.OpenSearchVersionInfo$Builder.build(OpenSearchVersionInfo.java:214) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:93) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:56) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:85) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:189) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:150) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:88) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:92) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:56) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.transport.aws.AwsSdk2Transport.parseResponse(AwsSdk2Transport.java:522) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.transport.aws.AwsSdk2Transport.executeSync(AwsSdk2Transport.java:393) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.transport.aws.AwsSdk2Transport.performRequest(AwsSdk2Transport.java:191) ~[opensearch-java-2.6.0.jar!/:na]
at org.opensearch.client.opensearch.OpenSearchClient.info(OpenSearchClient.java:860) ~[opensearch-java-2.6.0.jar!/:na]
How can one reproduce the bug?
- Create an AWS OpenSearch domain running version 2.7 (the latest version AWS supports currently).
- Create your
OpenSearchClient:
var client = new OpenSearchClient(
new AwsSdk2Transport(
ApacheHttpClient.builder().build(),
opensearchHost,
"es",
Region.US_WEST_2,
AwsSdk2TransportOptions.builder().build()
)
);
- Attempt to fetch information on the cluster:
var clusterName = client.info().clusterName();
What is the expected behavior?
I wouldn’t expect this to result in an exception, but rather print the cluster information even if the distribution is missing.
What is your host/environment?
AWS OpenSearch 2.7 (the latest version AWS supports currently)
Do you have any screenshots?
N/A
Do you have any additional context?
If the fix for this issue is as simple as refactoring the following line, I’d be happy to PR it:
this.distribution = ApiTypeHelper.requireNonNull(builder.distribution, this, "distribution");
For now, I’m going to avoid fetching the cluster information on startup as a temporary solution.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (5 by maintainers)
Faced the same issue today and had to set
compatibility.override_main_response_versionto false.This will add the property
"distribution" : "opensearch"in the cluster info response.If you are running a managed version of opensearch like on AWS, you need to contact AWS support to update this setting.
I believe the answer is no, there’s no claims of opensearch-java working with Elasticsearch 7.10.
@jhg023 So yes, this is compatibility mode. When you create a new domain there’s a checkbox to enable/disable it. If you don’t need this, you can toggle it via API
I’m going to close this, but feel free to keep the conversation open as needed.
Docs for compatibility mode: https://opensearch.org/docs/latest/tools/index/#agents-and-ingestion-tools
I created a 2.7 domain and I cannot reproduce this, I see distribution below. What do you see @jhg023?
Update: do you use OpenSearch in compatibility mode with
compatibility.override_main_response_version? That would do it I believe, which exists to support ES 7.10 clients exclusively. (thanks @andrross for the tip).In that case, I can open a support ticket to AWS to investigate.
Feel free to submit the PR to fix this. I think it makes sense.