Skip to content

Commit 627c9cc

Browse files
Add exclusions for unconsumed response parameters
1 parent 3ed9350 commit 627c9cc

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

server/src/main/java/org/elasticsearch/rest/BaseRestHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ private boolean assertConsumesSupportedParams(@Nullable Set<String> supported, R
154154
supportedAndCommon.removeAll(RestRequest.INTERNAL_MARKER_REQUEST_PARAMETERS);
155155
final var consumed = new TreeSet<>(request.consumedParams());
156156
consumed.removeAll(RestRequest.INTERNAL_MARKER_REQUEST_PARAMETERS);
157+
// Add exclusions for response parameters since they may not always be consumed for every request.
158+
final var unconsumedResponseParams = new HashSet<>(responseParams(request.getRestApiVersion()));
159+
unconsumedResponseParams.removeAll(consumed);
160+
supportedAndCommon.removeAll(unconsumedResponseParams);
157161
assert supportedAndCommon.equals(consumed)
158162
: getName() + ": consumed params " + consumed + " while supporting " + supportedAndCommon;
159163
}

server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestGetSnapshotsAction.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.elasticsearch.client.internal.node.NodeClient;
1515
import org.elasticsearch.common.Strings;
1616
import org.elasticsearch.common.util.set.Sets;
17-
import org.elasticsearch.core.Assertions;
1817
import org.elasticsearch.features.NodeFeature;
1918
import org.elasticsearch.rest.BaseRestHandler;
2019
import org.elasticsearch.rest.RestRequest;
@@ -140,14 +139,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
140139
throw new IllegalArgumentException("[state] parameter is not supported on all nodes in the cluster");
141140
}
142141

143-
// Consume these response parameters used in SnapshotInfo now, to avoid assertion errors in BaseRestHandler for requests where they
144-
// may not get used.
145-
if (Assertions.ENABLED) {
146-
for (final var responseParameter : SUPPORTED_RESPONSE_PARAMETERS) {
147-
request.param(responseParameter);
148-
}
149-
}
150-
151142
return channel -> new RestCancellableNodeClient(client, request.getHttpChannel()).admin()
152143
.cluster()
153144
.getSnapshots(getSnapshotsRequest, new RestRefCountedChunkedToXContentListener<>(channel));

0 commit comments

Comments
 (0)