Skip to content

Fix indices.shard_stores ShardStoreException to use ErrorCause schema - #1109

Open
sean- wants to merge 1 commit into
opensearch-project:mainfrom
sean-:fix-shard-store-exception-fields
Open

Fix indices.shard_stores ShardStoreException to use ErrorCause schema#1109
sean- wants to merge 1 commit into
opensearch-project:mainfrom
sean-:fix-shard-store-exception-fields

Conversation

@sean-

@sean- sean- commented May 15, 2026

Copy link
Copy Markdown
Collaborator

The server serializes store_exception via OpenSearchException.generateThrowableXContent (called from IndicesShardStoresResponse.StoreStatus.toXContent), which delegates to innerToXContent and produces the full ErrorCause shape. The previous schema only declared type and reason, causing typed clients to drop the index, index_uuid, and shard metadata fields that the server includes when the exception is associated with a specific shard (metadata keys are stripped of the opensearch. prefix before serialization).

Use allOf to extend ErrorCause with the three explicit exception metadata properties so code generators emit named fields for them (ErrorCause's additionalProperties catch-all is not rendered by most generators).

This serialization has been present since OpenSearch 1.0.0 (inherited from the Elasticsearch fork — the original _shard_stores API commit predates the rename). All OpenSearch versions emit the full ErrorCause shape for store_exception.

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.

The server serializes `store_exception` via
[`OpenSearchException.generateThrowableXContent`](https://github.com/opensearch-project/OpenSearch/blob/27333365da0d55a16bea2ebaf34f6f2a691f6d50/libs/core/src/main/java/org/opensearch/OpenSearchException.java#L601)
(called from [`IndicesShardStoresResponse.StoreStatus.toXContent`](https://github.com/opensearch-project/OpenSearch/blob/27333365da0d55a16bea2ebaf34f6f2a691f6d50/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java#L208-L209)),
which delegates to [`innerToXContent`](https://github.com/opensearch-project/OpenSearch/blob/27333365da0d55a16bea2ebaf34f6f2a691f6d50/libs/core/src/main/java/org/opensearch/OpenSearchException.java#L395-L446)
and produces the full ErrorCause shape. The previous schema only
declared `type` and `reason`, causing typed clients to drop the
[`index`, `index_uuid`, and `shard` metadata fields](https://github.com/opensearch-project/OpenSearch/blob/27333365da0d55a16bea2ebaf34f6f2a691f6d50/libs/core/src/main/java/org/opensearch/OpenSearchException.java#L96-L98)
that the server includes when the exception is associated with a
specific shard (metadata keys are [stripped of the `opensearch.` prefix](https://github.com/opensearch-project/OpenSearch/blob/27333365da0d55a16bea2ebaf34f6f2a691f6d50/libs/core/src/main/java/org/opensearch/OpenSearchException.java#L409)
before serialization).

Use `allOf` to extend ErrorCause with the three explicit exception
metadata properties so code generators emit named fields for them
(ErrorCause's `additionalProperties` catch-all is not rendered by
most generators).

This serialization has been present since OpenSearch 1.0.0 (inherited
from the Elasticsearch fork — the original `_shard_stores` API commit
predates the rename). All OpenSearch versions emit the full ErrorCause
shape for `store_exception`.

Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
@sean-
sean- force-pushed the fix-shard-store-exception-fields branch from d8ae730 to 24bc743 Compare May 19, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant