-
Notifications
You must be signed in to change notification settings - Fork 25.2k
fix: handle null path parameter in RestNodesCapabilitiesAction and pr… #113413
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
fix: handle null path parameter in RestNodesCapabilitiesAction and pr… #113413
Conversation
💚 CLA has been signed |
…event NPE - Added null check for the 'path' parameter in RestNodesCapabilitiesAction to avoid NullPointerException. - If 'path' is not provided, assign an empty string to ensure safe handling in the URLDecoder and other parts of the code. - Updated the response to return a valid node capabilities result with a successful outcome. - Ensured the request behaves properly when no path is provided, preventing crashes.
027e805
to
9796c99
Compare
@elasticsearchmachine Could you please assign a reviewer to this PR? Thank you! |
Pinging @elastic/es-core-infra (Team:Core/Infra) |
@@ -54,16 +54,26 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli | |||
? new NodesCapabilitiesRequest(client.getLocalNodeId()) | |||
: new NodesCapabilitiesRequest(); | |||
|
|||
// Handle the 'path' parameter safely, assign an empty string if null | |||
String path = request.param("path"); | |||
if (path != null) { |
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.
Instead of checking for null, we can just use the default value parameter:
.path(request.param("path", "/"))
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.
Hi @thecoop,
I've made the requested change to use request.param("path", "/") as the default value for the path parameter instead of checking for null. Please let me know if there are any further adjustments needed.
Thank you!
@elasticmachine test this |
@nbenliogludev Could you update your branch with latest from main? The changelog also needs to be updated - run |
@elasticmachine update branch |
@elasticmachine test this |
@thecoop, All checks have passed, and the branch is up to date. Could I please get a review and approval for the merge? |
All merged, thanks for the fix! |
Fix: handle null path parameter in RestNodesCapabilitiesAction and prevent NPE