ShardFailure response must not require the 'primary' property#1878
Open
janhoy wants to merge 1 commit intoopensearch-project:mainfrom
Open
ShardFailure response must not require the 'primary' property#1878janhoy wants to merge 1 commit intoopensearch-project:mainfrom
janhoy wants to merge 1 commit intoopensearch-project:mainfrom
Conversation
Signed-off-by: Jan Høydahl <jan.git@cominvent.com>
janhoy
commented
Feb 13, 2026
| .with(schema("_common", "StringifiedVersionNumber"), so -> so.withMappedType(Types.Primitive.Long)) | ||
| .with(schema("_common", "Void"), so -> so.withMappedType(Types.Primitive.Void)) | ||
|
|
||
| .with(schema("_common", "ShardFailure"), so -> so.withProperties(p -> p.with("primary", po -> po.withRequired(false)))) |
Contributor
Author
There was a problem hiding this comment.
This solution was chosen by Claude Code. I thought it might be possible to encode the non-null rule in the spec itself over in https://github.com/opensearch-project/opensearch-api-specification/ but I don't have any experience with that repo, so feel free to take this as a reproduction PR if you want to solve it in a different way.
janhoy
commented
Feb 13, 2026
| ### Fixed | ||
| - Fix formatting of the main method to run for various samples ([#1749](https://github.com/opensearch-project/opensearch-java/pull/1749)) | ||
| - Fix NPE when null ObjectBuilder is accessed ([#1717](https://github.com/opensearch-project/opensearch-java/issues/1717)) | ||
| - Fixed deserialization failure when OpenSearch returns shard failures without the `primary` field in error responses ([#XXXX](https://github.com/opensearch-project/opensearch-java/pull/XXXX)) |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| - Fixed deserialization failure when OpenSearch returns shard failures without the `primary` field in error responses ([#XXXX](https://github.com/opensearch-project/opensearch-java/pull/XXXX)) | |
| - Fixed deserialization failure when OpenSearch returns shard failures without the `primary` field in error responses ([#1878](https://github.com/opensearch-project/opensearch-java/pull/1878)) |
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
When a request returns error with
failed_shards, the current json parsing code requires that the shard object has aprimaryboolean property, but that is not always the case. The requirement was introduced in opensearch-project/opensearch-api-specification#981Issues Resolved
Closes #1877
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.
Disclaimer: I have generated the reproduction test and the fix with AI assistant, and then manually reviewed and accepted the solution