Skip to content

Commit

Permalink
Allow additional path parameters to be added for capabilities validat…
Browse files Browse the repository at this point in the history
…ion (#108901)
  • Loading branch information
thecoop authored May 22, 2024
1 parent 7e09df7 commit b591afc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public final long getUsageCount() {
@Override
public final void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception {
// check if the query has any parameters that are not in the supported set (if declared)
Set<String> supported = supportedQueryParameters();
Set<String> supported = allSupportedParameters();
if (supported != null) {
var allSupported = Sets.union(ALWAYS_SUPPORTED, supported);
if (allSupported.containsAll(request.params().keySet()) == false) {
Expand Down
12 changes: 12 additions & 0 deletions server/src/main/java/org/elasticsearch/rest/RestHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ default List<Route> routes() {
return Collections.emptyList();
}

/**
* The set of path and query parameters that could be present on this handler.
* This method is only required due to <a href="https://github.com/elastic/elasticsearch/issues/36785">#36785</a>,
* which conflates query and path parameters inside the rest handler.
* This method should be overridden to add path parameters to {@link #supportedQueryParameters}
* if the handler has path parameters.
* This method will be removed when {@link #supportedQueryParameters()} and {@link BaseRestHandler#responseParams()} are combined.
*/
default @Nullable Set<String> allSupportedParameters() {
return supportedQueryParameters();
}

/**
* The set of query parameters accepted by this rest handler,
* {@code null} if query parameters should not be checked nor validated.
Expand Down

0 comments on commit b591afc

Please sign in to comment.