Skip to content

cluster/allocation/explain Query Parameters #4939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2025

Conversation

joshua-adams-1
Copy link
Contributor


Change Details

Extends the documentation for the cluster/allocation/explain API after query parameter support was added in elastic/elasticsearch#129342


Release

To be merged after elastic/elasticsearch#129342


Github Issue - elastic/elasticsearch#127028
Jira Ticket - ES-11865

Extends the documentation for the `cluster/allocation/explain` API after query parameter support was added in elastic/elasticsearch#129342
Copy link
Contributor

Following you can find the validation changes against the target branch for the API.

API Status Request Response
cluster.allocation_explain 🔴 8/17 → 10/17 17/17

You can validate this API yourself by using the make validate target.

@joshua-adams-1 joshua-adams-1 added the skip-backport This pull request should not be backported label Jul 16, 2025
Comment on lines +56 to +59
/**
* If true, returns an explanation for the primary shard for the specified shard ID.
*/
primary?: boolean
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to the ElasticSearch API, it is documented that we facilitate strings to be passed for boolean values. I was adding YAML Rest Tests to ensure that if a user is to do so, we correctly parse this and proceed as expected.

A separate question, why is validation here subjected to whether or not a YAML rest test exists / does not exist? What changes if I was to delete the test?

@pquentin
Copy link
Member

Looking more closely, we have YAML tests allowing different types in multiple places. Here is the full list of changes needed to make the validation pass. This won't give a good developer experience. I don't recommend applying this diff unless there's a good reason.

diff --git a/specification/cluster/allocation_explain/ClusterAllocationExplainRequest.ts b/specification/cluster/allocation_explain/ClusterAllocationExplainRequest.ts
index 50cda8f21..5bffd3ce4 100644
--- a/specification/cluster/allocation_explain/ClusterAllocationExplainRequest.ts
+++ b/specification/cluster/allocation_explain/ClusterAllocationExplainRequest.ts
@@ -48,15 +48,15 @@ export interface Request extends RequestBase {
     /**
      * The name of the index that you would like an explanation for.
      */
-    index?: IndexName
+    index?: IndexName | integer
     /**
      * An identifier for the shard that you would like an explanation for.
      */
-    shard?: integer
+    shard?: integer | string
     /**
      * If true, returns an explanation for the primary shard for the specified shard ID.
      */
-    primary?: boolean
+    primary?: boolean | string
     /**
      * Explain a shard only if it is currently located on the specified node name or node ID.
      */
@@ -65,12 +65,12 @@ export interface Request extends RequestBase {
      * If true, returns information about disk usage and shard sizes.
      * @server_default false
      */
-    include_disk_info?: boolean
+    include_disk_info?: boolean | string
     /**
      * If true, returns YES decisions in explanation.
      * @server_default false
      */
-    include_yes_decisions?: boolean
+    include_yes_decisions?: boolean | string
     /**
      * Period to wait for a connection to the master node.
      * @server_default 30s
@@ -85,11 +85,11 @@ export interface Request extends RequestBase {
     /**
      * An identifier for the shard that you would like an explanation for.
      */
-    shard?: integer
+    shard?: integer | string
     /**
      * If true, returns an explanation for the primary shard for the specified shard ID.
      */
-    primary?: boolean
+    primary?: boolean | string
     /**
      * Explain a shard only if it is currently located on the specified node name or node ID.
      */

Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM. Validation fails but this will be fixed by removing some YAML tests from Elasticsearch.

@joshua-adams-1 joshua-adams-1 merged commit 4a040b6 into main Jul 17, 2025
9 of 10 checks passed
@joshua-adams-1 joshua-adams-1 deleted the josh-adams-cluster-allocation-explain branch July 17, 2025 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-backport This pull request should not be backported specification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants