diff --git a/data-prepper-core/src/main/java/org/opensearch/dataprepper/core/parser/PipelineTransformer.java b/data-prepper-core/src/main/java/org/opensearch/dataprepper/core/parser/PipelineTransformer.java index 77cf649535..1b2a9f7d04 100644 --- a/data-prepper-core/src/main/java/org/opensearch/dataprepper/core/parser/PipelineTransformer.java +++ b/data-prepper-core/src/main/java/org/opensearch/dataprepper/core/parser/PipelineTransformer.java @@ -176,10 +176,6 @@ private void buildPipelineFromConfiguration( .map(this::buildRoutedSinkOrConnector) .collect(Collectors.toList()); - final List subPipelinePluginErrors = pluginErrorCollector.getPluginErrors() - .stream().filter(pluginError -> pipelineName.equals(pluginError.getPipelineName())) - .collect(Collectors.toList()); - final List invalidRouteExpressions = pipelineConfiguration.getRoutes() .stream().filter(route -> !expressionEvaluator.isValidExpressionStatement(route.getCondition())) .map(route -> PluginError.builder() @@ -190,8 +186,12 @@ private void buildPipelineFromConfiguration( .build()) .collect(Collectors.toList()); - if (!subPipelinePluginErrors.isEmpty() || !invalidRouteExpressions.isEmpty()) { - subPipelinePluginErrors.addAll(invalidRouteExpressions); + invalidRouteExpressions.forEach(pluginErrorCollector::collectPluginError); + final List subPipelinePluginErrors = pluginErrorCollector.getPluginErrors() + .stream().filter(pluginError -> pipelineName.equals(pluginError.getPipelineName())) + .collect(Collectors.toList()); + + if (!subPipelinePluginErrors.isEmpty()) { pluginErrorsHandler.handleErrors(subPipelinePluginErrors); throw new InvalidPluginConfigurationException( String.format("One or more plugins are not configured correctly in the pipeline: %s.\n", diff --git a/data-prepper-core/src/test/java/org/opensearch/dataprepper/core/parser/PipelineTransformerTests.java b/data-prepper-core/src/test/java/org/opensearch/dataprepper/core/parser/PipelineTransformerTests.java index 9caa18820f..300850d9c9 100644 --- a/data-prepper-core/src/test/java/org/opensearch/dataprepper/core/parser/PipelineTransformerTests.java +++ b/data-prepper-core/src/test/java/org/opensearch/dataprepper/core/parser/PipelineTransformerTests.java @@ -396,6 +396,7 @@ void parseConfiguration_with_invalid_route_expressions_handles_errors_and_return final Collection pluginErrorCollection = pluginErrorArgumentCaptor.getValue(); assertThat(pluginErrorCollection, notNullValue()); assertThat(pluginErrorCollection.size(), equalTo(1)); + assertThat(pluginErrorCollector.getPluginErrors(), equalTo(pluginErrorCollection)); final PluginError pluginError = pluginErrorCollection.stream().findAny().orElseThrow(); final String expectedErrorMessage = String.format(CONDITIONAL_ROUTE_INVALID_EXPRESSION_FORMAT, "service", "/value == service");