-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[ES 9.0] Remove body workaround (@elastic/response-ops)
#217216
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
afharo
merged 6 commits into
elastic:main
from
afharo:es-9.0/remove-body-workaround/elastic/response-ops
Apr 11, 2025
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
51b5a7e
[ES 9.0] (Remove body workaround) `@elastic/response-ops`
afharo e725c6e
Merge branch 'main' of github.com:elastic/kibana into es-9.0/remove-b…
afharo 9bc80b5
Fix tests
afharo 2fd0409
Remove comment left-over
afharo f1729ff
Merge branch 'main' into es-9.0/remove-body-workaround/elastic/respon…
afharo a2880a7
Merge branch 'main' into es-9.0/remove-body-workaround/elastic/respon…
afharo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,8 +90,7 @@ const updateUnderlyingMapping = async ({ | |
|
|
||
| try { | ||
| await retryTransientEsErrors( | ||
| // @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584 | ||
| () => esClient.indices.putMapping({ index, body: simulatedMapping }), | ||
| () => esClient.indices.putMapping({ index, ...simulatedMapping }), | ||
| { logger } | ||
| ); | ||
|
|
||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,17 +50,19 @@ const getIndexTemplatesUsingComponentTemplate = async ( | |
| () => | ||
| esClient.indices.putIndexTemplate({ | ||
| name: template.name, | ||
| body: { | ||
| ...template.index_template, | ||
| // @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584 | ||
| template: { | ||
| ...template.index_template.template, | ||
| settings: { | ||
| ...template.index_template.template?.settings, | ||
| 'index.mapping.total_fields.limit': totalFieldsLimit, | ||
| }, | ||
| ...template.index_template, | ||
| template: { | ||
| ...template.index_template.template, | ||
| settings: { | ||
| ...template.index_template.template?.settings, | ||
| 'index.mapping.total_fields.limit': totalFieldsLimit, | ||
| }, | ||
| }, | ||
| // GET brings string | string[] | undefined but this PUT expects string[] | ||
| ignore_missing_component_templates: template.index_template | ||
| .ignore_missing_component_templates | ||
| ? [template.index_template.ignore_missing_component_templates].flat() | ||
| : undefined, | ||
| }), | ||
| { logger } | ||
| ); | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -339,13 +339,10 @@ export class ClusterClientAdapter< | |
| const esClient = await this.elasticsearchClientPromise; | ||
| await esClient.indices.putTemplate({ | ||
| name: indexTemplateName, | ||
| body: { | ||
| ...currentIndexTemplate, | ||
| // @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584 | ||
| settings: { | ||
| ...currentIndexTemplate.settings, | ||
| 'index.hidden': true, | ||
| }, | ||
| ...currentIndexTemplate, | ||
| settings: { | ||
| ...currentIndexTemplate.settings, | ||
| 'index.hidden': true, | ||
| }, | ||
| }); | ||
| } catch (err) { | ||
|
|
@@ -461,8 +458,7 @@ export class ClusterClientAdapter< | |
| const simulatedMapping = get(simulatedIndexMapping, ['template', 'mappings']); | ||
|
|
||
| if (simulatedMapping != null) { | ||
| // @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584 | ||
| await esClient.indices.putMapping({ index: name, body: simulatedMapping }); | ||
| await esClient.indices.putMapping({ index: name, ...simulatedMapping }); | ||
| this.logger.debug(`Successfully updated concrete index mappings for ${name}`); | ||
| } | ||
| } catch (err) { | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -902,21 +902,22 @@ export class TaskStore { | |
| { max_docs: max_docs }: UpdateByQueryOpts = {} | ||
| ): Promise<UpdateByQueryResult> { | ||
| const { query } = ensureQueryOnlyReturnsTaskObjects(opts); | ||
| const { sort, ...rest } = opts; | ||
| try { | ||
| const // @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584 types complain because the body should not be there. | ||
| // However, we can't use this API without the body because it fails to claim the tasks. | ||
| const // However, we can't use this API without the body because it fails to claim the tasks. | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| { total, updated, version_conflicts } = await this.esClientWithoutRetries.updateByQuery( | ||
| { | ||
| index: this.index, | ||
| ignore_unavailable: true, | ||
| refresh: true, | ||
| conflicts: 'proceed', | ||
| body: { | ||
| ...opts, | ||
| max_docs, | ||
| query, | ||
| }, | ||
| ...rest, | ||
| max_docs, | ||
| 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 }, | ||
| }, | ||
| { requestTimeout: this.requestTimeouts.update_by_query } | ||
| ); | ||
|
|
||
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.
There was a problem hiding this comment.
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
sortquerystring parameter is allowed (and the format is a comma-separated list of fields).However, this query has always sent
sortin the body (with an object format).There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.