Compare commits

...

1 Commits

Author SHA1 Message Date
YannC.
d2409aa538 fix: display check error message when an execution is blocked
close #13854
2025-12-29 17:21:35 +01:00
2 changed files with 39 additions and 2 deletions

View File

@@ -747,11 +747,13 @@ public class ExecutionController {
return flowInputOutput.readExecutionInputs(flow, current, inputs)
.flatMap(executionInputs -> {
Check.Behavior behavior = Check.resolveBehavior(flowService.getFailedChecks(flow, executionInputs));
List<Check> failed = flowService.getFailedChecks(flow, executionInputs);
Check.Behavior behavior = Check.resolveBehavior(failed);
if (Check.Behavior.BLOCK_EXECUTION.equals(behavior)) {
return Mono.error(new IllegalArgumentException(
"Flow execution blocked: one or more condition checks evaluated to false."
));
+ "\nFailed checks: " + failed.stream().map(Check::getMessage).collect(Collectors.joining(", ")
)));
}
final Execution executionWithInputs = Optional.of(current.withInputs(executionInputs))

View File

@@ -6,6 +6,7 @@ import io.kestra.core.models.Label;
import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.flows.Flow;
import io.kestra.core.models.flows.FlowForExecution;
import io.kestra.core.models.flows.check.Check;
import io.kestra.core.models.property.Property;
import io.kestra.core.models.tasks.TaskForExecution;
import io.kestra.core.models.triggers.AbstractTriggerForExecution;
@@ -530,6 +531,39 @@ class ExecutionControllerTest {
assertThat(csv).contains("id");
}
@Test
void shouldBlockExecutionAndThrowCheckErrorMessage() {
String namespaceId = "io.othercompany";
String flowId = "flowWithCheck";
createFlowWithFailingCheck(namespaceId, flowId);
HttpClientResponseException e = assertThrows(
HttpClientResponseException.class,
() ->
client.toBlocking().retrieve(
HttpRequest.POST("/api/v1/main/executions/" + namespaceId + "/" + flowId, null),
Execution.class
)
);
assertThat(e.getMessage()).contains("No VM provided");
}
void createFlowWithFailingCheck(String namespaceId, String flowId) {
Flow create = Flow.builder()
.id(flowId)
.tenantId(MAIN_TENANT)
.namespace(namespaceId)
.checks(List.of(Check.builder().condition("{{ [] | length > 0 }}").message("No VM provided").style(Check.Style.ERROR).behavior(Check.Behavior.BLOCK_EXECUTION).build()))
.tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format(Property.of("test")).build()))
.build();
client.toBlocking().retrieve(
HttpRequest.POST("/api/v1/main/flows", create),
Flow.class
);
}
void createAndExecuteFlow() {
String namespaceId = "io.othercompany";
String flowId = "flowId";
@@ -550,4 +584,5 @@ class ExecutionControllerTest {
Execution.class
);
}
}