diff --git a/RFS/src/main/java/org/opensearch/migrations/bulkload/version_universal/RemoteReaderClient.java b/RFS/src/main/java/org/opensearch/migrations/bulkload/version_universal/RemoteReaderClient.java index 2889a5868..a1838ba2b 100644 --- a/RFS/src/main/java/org/opensearch/migrations/bulkload/version_universal/RemoteReaderClient.java +++ b/RFS/src/main/java/org/opensearch/migrations/bulkload/version_universal/RemoteReaderClient.java @@ -121,8 +121,8 @@ Mono getJsonForTemplateApis(HttpResponse resp) { try { var tree = (ObjectNode) objectMapper.readTree(resp.body); - if (tree.size() == 1) { - return Mono.just(handleSingleItemTree(tree)); + if (tree.size() == 1 && tree.fields().next().getValue().isArray()) { + return Mono.just(handleSingleItemArrayValueTree(tree)); } return Mono.just(tree); @@ -131,13 +131,17 @@ Mono getJsonForTemplateApis(HttpResponse resp) { } } - private ObjectNode handleSingleItemTree(ObjectNode tree) { + private ObjectNode handleSingleItemArrayValueTree(ObjectNode tree) { var dearrayed = objectMapper.createObjectNode(); var fieldName = tree.fieldNames().next(); var arrayOfItems = tree.get(fieldName); for (var child : arrayOfItems) { - processChildNode((ObjectNode) child, dearrayed); + if (child.isObject()) { + processChildNode((ObjectNode) child, dearrayed); + } else { + throw new IllegalArgumentException("Expected ObjectNode, got: " + child.getNodeType()); + } } return dearrayed; diff --git a/RFS/src/testFixtures/java/org/opensearch/migrations/bulkload/framework/SearchClusterContainer.java b/RFS/src/testFixtures/java/org/opensearch/migrations/bulkload/framework/SearchClusterContainer.java index 05c8736e1..cbf485584 100644 --- a/RFS/src/testFixtures/java/org/opensearch/migrations/bulkload/framework/SearchClusterContainer.java +++ b/RFS/src/testFixtures/java/org/opensearch/migrations/bulkload/framework/SearchClusterContainer.java @@ -30,7 +30,7 @@ public class SearchClusterContainer extends GenericContainer