OpenSearch-Dashboards icon indicating copy to clipboard operation
OpenSearch-Dashboards copied to clipboard

Dev Tools should support PATCH method

Open peternied opened this issue 3 years ago • 2 comments

Reproduction:

  • Find some documentation about a scenario in OpenSearch APIs that use a PATCH command, like
  • Get excited to try it out in your own cluster
  • Open Dashboards, login as an admin user
  • Navigate to Dev Tools
  • Paste the following into the console window
PATCH _plugins/_security/api/roles/my_role
[
  {
    "op": "replace", "path": "/index_permissions/0/fls", "value": ["myfield1", "myfield2"]
  },
  {
    "op": "remove", "path": "/index_permissions/0/dls"
  }
]
  • Select that text and hit the 'send request' button

Expected:

The request should succeed

Actual:

An error message appears in the response window:

{"statusCode":400,"error":"Bad Request","message":"[request query.method]: Method must be one of, case insensitive ['HEAD', 'GET', 'POST', 'PUT', 'DELETE']. Received 'PATCH'."}

Be sad you can't use this great tool to vet the scenario called out in the documentation

peternied avatar Sep 13 '22 20:09 peternied

FYI @cwillum

peternied avatar Sep 13 '22 20:09 peternied

It seems that the request method simply isn't in the list here:

https://github.com/opensearch-project/OpenSearch-Dashboards/blob/06abe83e0180f391a84c742cf5594866bc747ea2/src/plugins/console/server/routes/api/console/proxy/validation_config.ts#L37-L43

Something else of note is that it looks like the website doesn't recognize PATCH methods either, which would most likely be an issue with code somewhere else.

Just by changing that, though, the error is just propagated through to Open Search, which ends up here:

https://github.com/opensearch-project/OpenSearch/blob/2bfe8b31af354e5d00e4ac67d544ce664f083934/server/src/main/java/org/opensearch/rest/RestController.java#L490-L506

BSFishy avatar Sep 20 '22 22:09 BSFishy

@peternied @BSFishy Is anything going on? Or is it just waiting for contributions?

10000-ki avatar Jun 03 '24 06:06 10000-ki

Waiting for a contribution, @10000-ki could you take it on?

peternied avatar Jun 03 '24 13:06 peternied