From f3c54f307688a49cca9a24a691c1bf1209dcd377 Mon Sep 17 00:00:00 2001 From: Taylor Gray Date: Mon, 13 Oct 2025 09:56:54 -0500 Subject: [PATCH] Fix delete_entries incorrect validation Signed-off-by: Taylor Gray --- .../mutateevent/DeleteEntryProcessorConfig.java | 2 +- .../mutateevent/DeleteEntryProcessorConfigTests.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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();