Skip to content

Commit

Permalink
FIX: include route validation error into collector (#5332)
Browse files Browse the repository at this point in the history
* MAINT: include route validation error into collector

Signed-off-by: George Chen <[email protected]>
  • Loading branch information
chenqi0805 authored Jan 14, 2025
1 parent 9b07d40 commit 5f51c2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@ private void buildPipelineFromConfiguration(
.map(this::buildRoutedSinkOrConnector)
.collect(Collectors.toList());

final List<PluginError> subPipelinePluginErrors = pluginErrorCollector.getPluginErrors()
.stream().filter(pluginError -> pipelineName.equals(pluginError.getPipelineName()))
.collect(Collectors.toList());

final List<PluginError> invalidRouteExpressions = pipelineConfiguration.getRoutes()
.stream().filter(route -> !expressionEvaluator.isValidExpressionStatement(route.getCondition()))
.map(route -> PluginError.builder()
Expand All @@ -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<PluginError> 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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ void parseConfiguration_with_invalid_route_expressions_handles_errors_and_return
final Collection<PluginError> 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");
Expand Down

0 comments on commit 5f51c2b

Please sign in to comment.