Repository: kestra-io/kestra
Issue: ForEachItem should be considered as dependencies 
Labels: bug

Standard `ForEachItem` 

```yaml 
id: for-each-item-no-wait
namespace: io.kestra.tests

inputs:
  - id: file
    type: FILE

tasks:
  - id: each
    type: io.kestra.core.tasks.flows.ForEachItem
    items: "{{ inputs.file }}"
    batch:
      rows: 4
    namespace: io.kestra.tests
    flowId: for-each-item-subflow
    wait: false
    transmitFailed: true
    inputs:
      items: "{{ taskrun.items }}"
```

is displaying any dependencies : 
![image](https://github.com/kestra-io/kestra/assets/2064609/62152bdf-e9db-4451-9c94-d34fe0411576)

It should be considered as a dependencies and don't break the dependencies graph


Issue comments:
ForEachItem is considered as a dependency, it just need the children from to exists

![image](https://github.com/kestra-io/kestra/assets/37600690/c47cfe26-63e7-410a-9673-7fbea30586ec)

Could you try inverting the creation, before the ForEach flow after the subflow please ?
As I remember, I've done by this way as I remember 

Pull request review comments:

Patch that resolved the issue:
diff --git a/core/src/main/java/io/kestra/core/tasks/flows/ChildFlowInterface.java b/core/src/main/java/io/kestra/core/tasks/flows/ChildFlowInterface.java
new file mode 100644
index 0000000000..907a3d1cee
--- /dev/null
+++ b/core/src/main/java/io/kestra/core/tasks/flows/ChildFlowInterface.java
@@ -0,0 +1,7 @@
+package io.kestra.core.tasks.flows;
+
+public interface ChildFlowInterface {
+    String getNamespace();
+
+    String getFlowId();
+}
diff --git a/core/src/main/java/io/kestra/core/tasks/flows/ForEachItem.java b/core/src/main/java/io/kestra/core/tasks/flows/ForEachItem.java
index 45e18358f1..070a82d8d0 100644
--- a/core/src/main/java/io/kestra/core/tasks/flows/ForEachItem.java
+++ b/core/src/main/java/io/kestra/core/tasks/flows/ForEachItem.java
@@ -173,7 +173,7 @@
         )
     }
 )
-public class ForEachItem extends Task implements FlowableTask<VoidOutput> {
+public class ForEachItem extends Task implements FlowableTask<VoidOutput>, ChildFlowInterface {
     @NotEmpty
     @PluginProperty(dynamic = true)
     @Schema(title = "The items to be split into batches and processed. Make sure to set it to Kestra's internal storage URI. This can be either the output from a previous task, formatted as `{{ outputs.task_id.uri }}`, or a FILE type input parameter, like `{{ inputs.myfile }}`. This task is optimized for files where each line represents a single item. Suitable file types include Amazon ION-type files (commonly produced by Query tasks), newline-separated JSON files, or CSV files formatted with one row per line and without a header. For files in other formats such as Excel, CSV, Avro, Parquet, XML, or JSON, it's recommended to first convert them to the ION format. This can be done using the conversion tasks available in the `io.kestra.plugin.serdes` module, which will transform files from their original format to ION.")
diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Subflow.java b/core/src/main/java/io/kestra/core/tasks/flows/Subflow.java
index b4ced584d1..ee67aacb80 100644
--- a/core/src/main/java/io/kestra/core/tasks/flows/Subflow.java
+++ b/core/src/main/java/io/kestra/core/tasks/flows/Subflow.java
@@ -60,7 +60,7 @@
         )
     }
 )
-public class Subflow extends Task implements ExecutableTask<Subflow.Output> {
+public class Subflow extends Task implements ExecutableTask<Subflow.Output>, ChildFlowInterface {
 
     static final String PLUGIN_FLOW_OUTPUTS_ENABLED = "outputs.enabled";
 


Test patch: