Skip to content

Conversation

@afharo
Copy link
Member

@afharo afharo commented Apr 4, 2025

Summary

Follow up to #213375: The latest version of the ES client fixed the issue elastic/elasticsearch-js#2584.

We should be able to remove all usages of // @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584.

Checklist

@afharo afharo self-assigned this Apr 4, 2025
@afharo afharo changed the title [ES 9.0] (Remove body workaround) @elastic/response-ops [ES 9.0] Remove body workaround (@elastic/response-ops) Apr 4, 2025
@afharo afharo added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// elasticsearch-js-9 Feature:elasticsearch labels Apr 4, 2025
@afharo afharo marked this pull request as ready for review April 7, 2025 12:57
@afharo afharo requested a review from a team as a code owner April 7, 2025 12:57
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

Comment on lines 918 to 920
// @ts-expect-error According to the docs, sort should be a comma-separated list of fields and goes in the querystring.
// However, this one is using a "body" format?
body: { sort },
Copy link
Member Author

Choose a reason for hiding this comment

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

@JoshMock, @pquentin, this is an interesting one:
According to the docs, only the sort querystring parameter is allowed (and the format is a comma-separated list of fields).
However, this query has always sent sort in the body (with an object format).

Copy link
Member

Choose a reason for hiding this comment

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

I know there are some APIs that are permissive about putting some query parameters in the body instead, but the spec may be more strict, intentionally or not. @pquentin I know this has come up a couple times recently in the spec; do we have a preference on how the spec handles things that can go in query or body?

Copy link
Member

Choose a reason for hiding this comment

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

The spec should reflect reality: if both are accepted it means that Elasticsearch has specific code for both, and we should encode it in the spec.

Then it's up to the clients to choose which one to use, usually the body form.

Also, note that in 9.x the documentation for endpoints is generated from the spec, which will avoid those discrepancies.

query,
// @ts-expect-error According to the docs, sort should be a comma-separated list of fields and goes in the querystring.
// However, this one is using a "body" format?
body: { sort },
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this saying we're formatting the sort wrong or this function is expecting the sort in the body field?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll let @JoshMock and @pquentin confirm.
But based on the documentation, body sort is not supported by ES. Although the fact that ES doesn't 400 these requests makes me think that's a "hidden feature".

Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

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

LGTM. Verified alerts and event log indices are installed and reinstalled successfully for both serverless and server-ful across restarts. Verified task manager update by queries continue to claim tasks as expected.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @afharo

@afharo afharo merged commit f7e9b4c into elastic:main Apr 11, 2025
10 checks passed
@afharo afharo deleted the es-9.0/remove-body-workaround/elastic/response-ops branch April 11, 2025 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting elasticsearch-js-9 Feature:elasticsearch release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants