Skip to content

Commit bfa1a8c

Browse files
authored
Fix ILM explain response to allow unknown fields (#38363)
IndexLifecycleExplainResponse did not allow unknown fields. This commit fixes the test and ConstructingObjectParser such that it allows unknown fields. Relates #36938 Backport of #38054
1 parent 5e9688b commit bfa1a8c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/indexlifecycle/IndexLifecycleExplainResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class IndexLifecycleExplainResponse implements ToXContentObject {
5454
private static final ParseField PHASE_EXECUTION_INFO = new ParseField("phase_execution");
5555

5656
public static final ConstructingObjectParser<IndexLifecycleExplainResponse, Void> PARSER = new ConstructingObjectParser<>(
57-
"index_lifecycle_explain_response",
57+
"index_lifecycle_explain_response", true,
5858
a -> new IndexLifecycleExplainResponse(
5959
(String) a[0],
6060
(boolean) a[1],

client/rest-high-level/src/test/java/org/elasticsearch/client/indexlifecycle/IndexLifecycleExplainResponseTests.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.ArrayList;
3434
import java.util.List;
3535
import java.util.Objects;
36+
import java.util.function.Predicate;
3637
import java.util.function.Supplier;
3738

3839
import static org.hamcrest.Matchers.containsString;
@@ -99,7 +100,16 @@ protected IndexLifecycleExplainResponse doParseInstance(XContentParser parser) t
99100

100101
@Override
101102
protected boolean supportsUnknownFields() {
102-
return false;
103+
return true;
104+
}
105+
106+
@Override
107+
protected Predicate<String> getRandomFieldsExcludeFilter() {
108+
return (field) ->
109+
// actions are plucked from the named registry, and it fails if the action is not in the named registry
110+
field.endsWith("phase_definition.actions")
111+
// This is a bytes reference, so any new fields are tested for equality in this bytes reference.
112+
|| field.contains("step_info");
103113
}
104114

105115
private static class RandomStepInfo implements ToXContentObject {

0 commit comments

Comments
 (0)