Repository: kestra-io/kestra
Issue: Execution topology view displays GraphUtils.java errors
Labels: bug

### Describe the issue


![image](https://github.com/kestra-io/kestra/assets/86264395/39941478-df01-43e6-80f7-18c4f04a9b2d)

![image](https://github.com/kestra-io/kestra/assets/86264395/004970e8-b29c-400a-b0b3-c90b2d9ae6cf)



```yaml
...
        at io.kestra.core.utils.GraphUtils.sequential(GraphUtils.java:152)
        at io.kestra.core.tasks.flows.Pause.tasksTree(Pause.java:95)
        at io.kestra.core.utils.GraphUtils.fillGraph(GraphUtils.java:273)
        at io.kestra.core.utils.GraphUtils.iterate(GraphUtils.java:225)
        at io.kestra.core.utils.GraphUtils.sequential(GraphUtils.java:152)
        at io.kestra.core.tasks.flows.Pause.tasksTree(Pause.java:95)
        at io.kestra.core.utils.GraphUtils.fillGraph(GraphUtils.java:273)
        at io.kestra.core.utils.GraphUtils.iterate(GraphUtils.java:225)
```

### Environment

- Kestra Version:
- Operating System (OS/Docker/Kubernetes):
- Java Version (if you don't run kestra in Docker):


Issue comments:
Can you copy/paste the flow YAML that trigger this exception?
```yaml
id: pause_resume
namespace: dev

tasks:
  - id: pause
    type: io.kestra.core.tasks.flows.Pause

  - id: after_pause
    type: io.kestra.core.tasks.log.Log
    message: Execution has been resumed!
```

Pull request review comments:

Patch that resolved the issue:
diff --git a/core/src/main/java/io/kestra/core/models/tasks/FlowableTask.java b/core/src/main/java/io/kestra/core/models/tasks/FlowableTask.java
index 7f5ea8b545..b0aec6868e 100644
--- a/core/src/main/java/io/kestra/core/models/tasks/FlowableTask.java
+++ b/core/src/main/java/io/kestra/core/models/tasks/FlowableTask.java
@@ -1,6 +1,7 @@
 package io.kestra.core.models.tasks;
 
 import io.kestra.core.models.annotations.PluginProperty;
+import io.kestra.core.models.hierarchies.AbstractGraph;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.kestra.core.exceptions.IllegalVariableEvaluationException;
 import io.kestra.core.models.executions.Execution;
@@ -27,9 +28,10 @@ public interface FlowableTask <T extends Output> {
     /**
      * Create the topology representation of a flowable task.
      * <p>
-     * A flowable task always contains subtask to it returns a cluster that displays the subtasks.
+     * If a flowable task contains subtask, it must return a cluster that displays the subtasks.
+     * If not, it must return a single GraphTask.
      */
-    GraphCluster tasksTree(Execution execution, TaskRun taskRun, List<String> parentValues) throws IllegalVariableEvaluationException;
+    AbstractGraph tasksTree(Execution execution, TaskRun taskRun, List<String> parentValues) throws IllegalVariableEvaluationException;
 
     /**
      * @return all child tasks including errors
diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Pause.java b/core/src/main/java/io/kestra/core/tasks/flows/Pause.java
index ca967805e3..c12f5b9c97 100644
--- a/core/src/main/java/io/kestra/core/tasks/flows/Pause.java
+++ b/core/src/main/java/io/kestra/core/tasks/flows/Pause.java
@@ -8,7 +8,9 @@
 import io.kestra.core.models.executions.NextTaskRun;
 import io.kestra.core.models.executions.TaskRun;
 import io.kestra.core.models.flows.State;
+import io.kestra.core.models.hierarchies.AbstractGraph;
 import io.kestra.core.models.hierarchies.GraphCluster;
+import io.kestra.core.models.hierarchies.GraphTask;
 import io.kestra.core.models.hierarchies.RelationType;
 import io.kestra.core.models.tasks.FlowableTask;
 import io.kestra.core.models.tasks.Task;
@@ -87,14 +89,16 @@ public class Pause extends Sequential implements FlowableTask<VoidOutput> {
     private List<Task> tasks;
 
     @Override
-    public GraphCluster tasksTree(Execution execution, TaskRun taskRun, List<String> parentValues) throws IllegalVariableEvaluationException {
-        GraphCluster subGraph = new GraphCluster(this, taskRun, parentValues, RelationType.SEQUENTIAL);
+    public AbstractGraph tasksTree(Execution execution, TaskRun taskRun, List<String> parentValues) throws IllegalVariableEvaluationException {
+        if (this.tasks == null || this.tasks.isEmpty()) {
+            return new GraphTask(this, taskRun, parentValues, RelationType.SEQUENTIAL);
+        }
 
-        List<Task> tasks = this.tasks != null && !this.tasks.isEmpty() ? this.tasks : List.of(this);
+        GraphCluster subGraph = new GraphCluster(this, taskRun, parentValues, RelationType.SEQUENTIAL);
 
         GraphUtils.sequential(
             subGraph,
-            tasks,
+            this.tasks,
             this.errors,
             taskRun,
             execution
diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Sequential.java b/core/src/main/java/io/kestra/core/tasks/flows/Sequential.java
index 6eca26a288..e48cb609a4 100644
--- a/core/src/main/java/io/kestra/core/tasks/flows/Sequential.java
+++ b/core/src/main/java/io/kestra/core/tasks/flows/Sequential.java
@@ -7,6 +7,7 @@
 import io.kestra.core.models.executions.Execution;
 import io.kestra.core.models.executions.NextTaskRun;
 import io.kestra.core.models.executions.TaskRun;
+import io.kestra.core.models.hierarchies.AbstractGraph;
 import io.kestra.core.models.hierarchies.GraphCluster;
 import io.kestra.core.models.hierarchies.RelationType;
 import io.kestra.core.models.tasks.FlowableTask;
@@ -73,7 +74,7 @@ public class Sequential extends Task implements FlowableTask<VoidOutput> {
     private List<Task> tasks;
 
     @Override
-    public GraphCluster tasksTree(Execution execution, TaskRun taskRun, List<String> parentValues) throws IllegalVariableEvaluationException {
+    public AbstractGraph tasksTree(Execution execution, TaskRun taskRun, List<String> parentValues) throws IllegalVariableEvaluationException {
         GraphCluster subGraph = new GraphCluster(this, taskRun, parentValues, RelationType.SEQUENTIAL);
 
         GraphUtils.sequential(


Test patch: