diff --git a/data-prepper-plugins/mutate-event-processors/src/main/java/org/opensearch/dataprepper/plugins/processor/mutateevent/DeleteEntryProcessorConfig.java b/data-prepper-plugins/mutate-event-processors/src/main/java/org/opensearch/dataprepper/plugins/processor/mutateevent/DeleteEntryProcessorConfig.java index 392f20626e..755c5b603a 100644 --- a/data-prepper-plugins/mutate-event-processors/src/main/java/org/opensearch/dataprepper/plugins/processor/mutateevent/DeleteEntryProcessorConfig.java +++ b/data-prepper-plugins/mutate-event-processors/src/main/java/org/opensearch/dataprepper/plugins/processor/mutateevent/DeleteEntryProcessorConfig.java @@ -194,7 +194,7 @@ boolean hasOnlyOneConfiguration() { @AssertTrue(message = "exclude_from_delete only applies when with_keys_regex is configured.") boolean isExcludeFromDeleteValid() { - return excludeFromDelete != null && !excludeFromDelete.isEmpty() && withKeysRegex != null && !withKeysRegex.isEmpty(); + return !((excludeFromDelete != null && !excludeFromDelete.isEmpty()) && (withKeysRegex == null || withKeysRegex.isEmpty())); } @JsonIgnore diff --git a/data-prepper-plugins/mutate-event-processors/src/test/java/org/opensearch/dataprepper/plugins/processor/mutateevent/DeleteEntryProcessorConfigTests.java b/data-prepper-plugins/mutate-event-processors/src/test/java/org/opensearch/dataprepper/plugins/processor/mutateevent/DeleteEntryProcessorConfigTests.java index 7e6ba4ac8a..7dc2c4dd1e 100644 --- a/data-prepper-plugins/mutate-event-processors/src/test/java/org/opensearch/dataprepper/plugins/processor/mutateevent/DeleteEntryProcessorConfigTests.java +++ b/data-prepper-plugins/mutate-event-processors/src/test/java/org/opensearch/dataprepper/plugins/processor/mutateevent/DeleteEntryProcessorConfigTests.java @@ -42,6 +42,15 @@ void testisExcludeFromDeleteValid_with_valid_config() throws NoSuchFieldExceptio assertThat(objectUnderTest.isExcludeFromDeleteValid(), equalTo(true)); } + @Test + void test_with_keys_valid_config() throws NoSuchFieldException, IllegalAccessException{ + final DeleteEntryProcessorConfig objectUnderTest = new DeleteEntryProcessorConfig(); + final List regexKeys = List.of("test.*"); + ReflectivelySetField.setField(DeleteEntryProcessorConfig.class, objectUnderTest, "withKeys", regexKeys); + + assertThat(objectUnderTest.isExcludeFromDeleteValid(), equalTo(true)); + } + @Test void testisExcludeFromDeleteValid_with_invalid_config() throws NoSuchFieldException, IllegalAccessException{ final DeleteEntryProcessorConfig objectUnderTest = new DeleteEntryProcessorConfig();