mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-29 18:00:23 -05:00
Compare commits
1 Commits
develop
...
fix/issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2409aa538 |
@@ -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))
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user