diff --git a/data-prepper-core/src/main/java/org/opensearch/dataprepper/plugin/ExtensionPluginConfigurationConverter.java b/data-prepper-core/src/main/java/org/opensearch/dataprepper/plugin/ExtensionPluginConfigurationConverter.java index 83b569239a..02ed3af01a 100644 --- a/data-prepper-core/src/main/java/org/opensearch/dataprepper/plugin/ExtensionPluginConfigurationConverter.java +++ b/data-prepper-core/src/main/java/org/opensearch/dataprepper/plugin/ExtensionPluginConfigurationConverter.java @@ -12,6 +12,7 @@ import javax.inject.Inject; import javax.inject.Named; import java.time.Duration; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -49,7 +50,8 @@ public Object convert(final Class extensionPluginConfigurationType, final Str final Object configuration = convertSettings(extensionPluginConfigurationType, extensionProperties.get(rootKey)); - final Set> constraintViolations = validator.validate(configuration); + final Set> constraintViolations = configuration == null ? Collections.emptySet() : + validator.validate(configuration); if (!constraintViolations.isEmpty()) { final String violationsString = constraintViolations.stream() diff --git a/data-prepper-core/src/test/java/org/opensearch/dataprepper/plugin/ExtensionPluginConfigurationConverterTest.java b/data-prepper-core/src/test/java/org/opensearch/dataprepper/plugin/ExtensionPluginConfigurationConverterTest.java index b4d5c36dff..bbee113e59 100644 --- a/data-prepper-core/src/test/java/org/opensearch/dataprepper/plugin/ExtensionPluginConfigurationConverterTest.java +++ b/data-prepper-core/src/test/java/org/opensearch/dataprepper/plugin/ExtensionPluginConfigurationConverterTest.java @@ -76,7 +76,6 @@ void convert_with_test_extension_with_config() { @Test void convert_with_null_rootKey_value_should_return_null() { - when(validator.validate(any())).thenReturn(Collections.emptySet()); when(pipelinesDataFlowModel.getPipelineExtensions()).thenReturn(pipelineExtensions); final String rootKey = "test_extension"; when(pipelineExtensions.getExtensionMap()).thenReturn(Collections.emptyMap()); @@ -86,7 +85,9 @@ void convert_with_null_rootKey_value_should_return_null() { @Test void convert_should_throw_exception_when_there_are_constraint_violations() { + when(pipelinesDataFlowModel.getPipelineExtensions()).thenReturn(pipelineExtensions); final String rootKey = UUID.randomUUID().toString(); + when(pipelineExtensions.getExtensionMap()).thenReturn(Map.of(rootKey, Collections.emptyMap())); final String errorMessage = UUID.randomUUID().toString(); given(constraintViolation.getMessage()).willReturn(errorMessage); final String propertyPathString = UUID.randomUUID().toString();