Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot provide a body param to shutdown.putNode #1695

Closed
lukeelmers opened this issue May 19, 2022 · 0 comments
Closed

Cannot provide a body param to shutdown.putNode #1695

lukeelmers opened this issue May 19, 2022 · 0 comments

Comments

@lukeelmers
Copy link
Member

馃悰 Bug Report

It is not possible to provide a body when calling shutdown.putNode, and ES requires a body for this API. It appears that body is being defaulted to undefined but it is never overwritten if params.body is provided:

const body = undefined
for (const key in params) {
if (acceptedPath.includes(key)) {
continue
} else if (key !== 'body') {
// @ts-expect-error
querystring[key] = params[key]
}
}
const method = 'PUT'
const path = `/_nodes/${encodeURIComponent(params.node_id.toString())}/shutdown`
return await this.transport.request({ path, method, querystring, body }, options)

To Reproduce

Steps to reproduce the behavior:

      await client.shutdown.putNode({
        node_id: 'test_node_01',
        // ts also complains about the presence of `body`, so you need a @ts-expect-error
        body: {
          type: 'restart',
          reason: 'testing shutdown',
          allocation_delay: '20m',
        },
      });

Response:

ResponseError: parse_exception: [parse_exception] Reason: request body is required

Expected behavior

The provided body should be passed to ES, and the TS types shouldn't complain about it.

Your Environment

  • node version: 16.4.2
  • @elastic/elasticsearch version: 8.2.0-canary.2 (but I suspect this has been present for several versions now)
  • os: Mac
  • discovered this while writing an integration test for Kibana that attempted to use the node shutdown API
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

No branches or pull requests

2 participants