Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions spec/schemas/_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -322,22 +322,22 @@ components:
ShardFailure:
type: object
properties:
index:
_index:
$ref: '#/components/schemas/IndexName'
node:
_node:
type: string
reason:
$ref: '#/components/schemas/ErrorCause'
shard:
_shard:
type: integer
status:
type: string
primary:
type: boolean
required:
- _shard
- primary
- reason
- shard

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the server code, sorry I don't think removing shard from required is the right fix here.

ShardFailure schema is used inside ShardInfo.failures (line 315), which corresponds to ReplicationResponse.ShardInfo.Failure on the server side. that class always writes the shard field, it never omits it:

builder.field(_SHARD, shardId.id());
builder.field(_INDEX, shardId.getIndexName());
builder.field(_NODE, nodeId);

real problem is a field name mismatch. server writes _shard, _index, _node (with underscores), but this spec defines them as shard, index, node (without underscores). so the Java client looks for shard in the JSON, doesn't find it because the actual key is _shard, and throws MissingRequiredPropertyException.

making shard optional just hides this, client will silently get null instead of the actual shard ID. fix should be correcting the property names to match what the server actually returns.

Can you check the actual JSON response from the server that triggered the original issue? I'd expect the fields are there but named _shard, _index, _node.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks for checking the server code. You're right, removing shard from required just masked the real bug. Fixed in 646c39d: renamed index/node/shard to _index/_node/_shard to match what ReplicationResponse.ShardInfo.Failure actually writes, and restored _shard as required since the server always includes it. Also updated the PR title/description accordingly.

ShardSearchFailure:
type: object
description: Represents a failure to search on a specific shard. Used in search responses.
Expand Down