Fix ShardFailure serializing wrong JSON keys (index/node/shard instead of _index/_node/_shard) - #2037
Open
gingeekrishna wants to merge 5 commits into
Conversation
gingeekrishna
requested review from
Bukhtawar,
VachaShah,
Xtansia,
madhusudhankonda,
saratvemulapalli and
szczepanczykd
as code owners
July 5, 2026 07:36
gingeekrishna
added a commit
to gingeekrishna/opensearch-java
that referenced
this pull request
Jul 5, 2026
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
gingeekrishna
force-pushed
the
fix/1799-shardfailure-shard-nullable
branch
from
August 16, 2026 16:10
2dfacc8 to
a80639b
Compare
gingeekrishna
added a commit
to gingeekrishna/opensearch-java
that referenced
this pull request
Aug 16, 2026
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
reta
reviewed
Aug 16, 2026
Collaborator
There was a problem hiding this comment.
Please submit a change against https://github.com/opensearch-project/openSearch-api-specification, thank you
Author
There was a problem hiding this comment.
Submitted the spec fix upstream: opensearch-project/opensearch-api-specification#1194
reta
requested changes
Aug 16, 2026
2 tasks
Author
|
Submitted the spec fix upstream: opensearch-project/opensearch-api-specification#1194 |
gingeekrishna
added a commit
to gingeekrishna/opensearch-java
that referenced
this pull request
Aug 30, 2026
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
gingeekrishna
force-pushed
the
fix/1799-shardfailure-shard-nullable
branch
from
August 30, 2026 06:25
a80639b to
9768fe8
Compare
…rsing_exception The _common___DerivedField schema in opensearch-openapi.yaml included a required name property. This caused DerivedField.java to serialize a name key into the JSON mapping body, but the OpenSearch API does not accept name inside a derived field definition and returns: mapper_parsing_exception: unknown parameter [name] on mapper In the API, the derived field's name is expressed as the map key in the parent derived object, not as a property inside the field definition. Remove name from the _common___DerivedField schema (both from properties and required) and update the generated DerivedField.java accordingly. The Java client no longer serializes name inside derived field definitions. Fixes opensearch-project#1937 Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
…ailure ShardFailure.shard was marked as required in the spec, so the generated class threw MissingRequiredPropertyException when OpenSearch returned a ShardFailure without the shard field — masking the real failure. Per the OpenSearch API, shard is an optional integer in ShardFailure (the primary failure reason is always present; the shard number may be absent for certain failure types). Remove shard from the required list in _common___ShardFailure and update the generated ShardFailure.java to use @nullable Integer with proper null guards in serialization, hashCode, and equals. Fixes opensearch-project#1799 Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
The previous commit made shard optional, on the assumption the server sometimes omits it. Per review on the corresponding spec change (opensearch-project/opensearch-api-specification#1194), that was wrong: ReplicationResponse.ShardInfo.Failure on the server always writes the field. The real bug was a JSON key mismatch: the server writes _index, _shard, _node (underscore-prefixed), but the spec and this client used index, shard, node, so deserialization looked up the wrong key and threw MissingRequiredPropertyException on _shard/shard, or silently dropped _index/_node. Revert shard to a required, non-null int, and rename the three JSON keys (index/node/shard -> _index/_node/_shard) in both opensearch-openapi.yaml and the generated ShardFailure.java. Java accessor/builder names are unchanged (index(), node(), shard()) per the existing convention for underscore-prefixed API fields (see Hit.index() for _index). Signed-off-by: Radhakrishnan P <gingeekrishna@gmail.com>
Signed-off-by: Radhakrishnan P <gingeekrishna@gmail.com>
gingeekrishna
force-pushed
the
fix/1799-shardfailure-shard-nullable
branch
from
September 4, 2026 05:54
b0231e4 to
d19fd14
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #1799
Problem: When OpenSearch returns a
ShardFailure, the Java client throwsMissingRequiredPropertyException: Missing required property 'ShardFailure.shard'.Root cause: This was originally diagnosed as
shardbeing incorrectly required. That diagnosis was wrong.ReplicationResponse.ShardInfo.Failureon the server always writes the field — the real bug is a JSON key mismatch: the server writes_index,_shard,_node(underscore-prefixed), while_common___ShardFailureinopensearch-openapi.yamland the generatedShardFailure.javausedindex,shard,node(no prefix). So the client looked up the wrong key:shardwas never found under that name, producing theMissingRequiredPropertyException, andindex/nodewere silently dropped since they aren't required.This surfaced during review of the corresponding spec fix, opensearch-project/opensearch-api-specification#1194.
Fix:
java-codegen/opensearch-openapi.yaml— renameindex/node/shardto_index/_node/_shardin_common___ShardFailure; keep_shardrequired (reverting an earlier, incorrect attempt to make it optional).java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardFailure.java— rename the three JSON keys used in serialization/deserialization to match. Java accessor/builder names are unchanged (index(),node(),shard()), consistent with existing underscore-prefixed fields elsewhere (e.g.Hit.index()for_index).Changes
java-codegen/opensearch-openapi.yaml— renameindex/node/shardto_index/_node/_shard; keep_shardrequiredjava-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardFailure.java— rename JSON keys inserializeInternal/setupShardFailureDeserializer;shardstays a required, non-nullint