Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/130776.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 130776
summary: Fix msearch request parsing when index expression is null
area: Search
type: bug
issues:
- 129631
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,9 @@ public static Map<String, Object> nodeMapValue(Object node, String desc) {
* Otherwise the node is treated as a comma-separated string.
*/
public static String[] nodeStringArrayValue(Object node) {
if (node == null) {
throw new ElasticsearchParseException("Expected a list of strings but got null");
}
if (isArray(node)) {
List<?> list = (List<?>) node;
String[] arr = new String[list.size()];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package org.elasticsearch.action.search;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.CheckedBiConsumer;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -537,6 +538,14 @@ public void testFailOnExtraCharacters() throws IOException {
}
}

public void testNullIndex() throws IOException {
try {
MultiSearchRequest request = parseMultiSearchRequest("/org/elasticsearch/action/search/msearch-null.json");
} catch (ElasticsearchParseException e) {
assertThat(e.getMessage(), containsString("Expected a list of strings but got null"));
}
}

private static MultiSearchRequest mutate(MultiSearchRequest searchRequest) throws IOException {
MultiSearchRequest mutation = copyRequest(searchRequest);
List<CheckedRunnable<IOException>> mutators = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"index": null}
{"query" : {"match_all" : {}}}
Loading