Skip to content

Commit

Permalink
fix: handle null path parameter in RestNodesCapabilitiesAction (elast…
Browse files Browse the repository at this point in the history
  • Loading branch information
nbenliogludev authored Sep 27, 2024
1 parent 074af78 commit 929b388
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/changelog/113413.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 113413
summary: Fixed a `NullPointerException` in `_capabilities` API when the `path` parameter is null.
area: Infra/REST API
type: bug
issues:
- 113413
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
? new NodesCapabilitiesRequest(client.getLocalNodeId())
: new NodesCapabilitiesRequest();

// Handle the 'path' parameter, use "/" as default if not provided
String path = URLDecoder.decode(request.param("path", "/"), StandardCharsets.UTF_8);

NodesCapabilitiesRequest r = requestNodes.timeout(getTimeout(request))
.method(RestRequest.Method.valueOf(request.param("method", "GET")))
.path(URLDecoder.decode(request.param("path"), StandardCharsets.UTF_8))
.path(path)
.parameters(request.paramAsStringArray("parameters", Strings.EMPTY_ARRAY))
.capabilities(request.paramAsStringArray("capabilities", Strings.EMPTY_ARRAY))
.restApiVersion(request.getRestApiVersion());
Expand Down

0 comments on commit 929b388

Please sign in to comment.