Repository: kestra-io/kestra
File: core/src/main/java/io/kestra/plugin/core/flow/ForEach.java (Java)

Code before:
import io.kestra.core.utils.GraphUtils;
import io.kestra.core.utils.ListUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PositiveOrZero;
import lombok.*;
import lombok.experimental.SuperBuilder;

import java.util.List;
import java.util.Optional;

@SuperBuilder
@ToString
@EqualsAndHashCode
@Getter
@NoArgsConstructor
@Schema(
    title = "Execute a group of tasks for each value in the list.",
    description = """
        You can control how many task groups are executed concurrently by setting the `concurrencyLimit` property. \

        - A `concurrencyLimit` of `0` means no limit — all task groups run in parallel. \

        - A `concurrencyLimit` of `1` means full serialization — only one task group runs at a time, in order. \

        - A `concurrencyLimit` greater than `1` allows up to that number of task groups to run in parallel, with the rest queued until capacity becomes available. \


        Regardless of the `concurrencyLimit` property, the `tasks` will run one after the other — to run those in parallel, wrap them in a [Parallel](https://kestra.io/plugins/core/tasks/flow/io.kestra.plugin.core.flow.parallel) task as shown in the last example below (_see the flow `parallel_tasks_example`_). \


        The `values` can be defined as a JSON string or an array, e.g. a list of string values `["value1", "value2"]` or a list of key-value pairs `[{"key": "value1"}, {"key": "value2"}]`.\s


        Access the current iteration value using `{{ taskrun.value }}` \
        or `{{ parent.taskrun.value }}` when inside a nested child task. \
        The iteration number is available via `{{ taskrun.iteration }}`. \


        If you need to execute more than 2-5 tasks for each value, we recommend triggering a subflow for each value for better performance and modularity. \
        See the [flow best practices documentation](https://kestra.io/docs/best-practices/flows) for more details."""
)
@Plugin(
    examples = {
        @Example(
            full = true,
            title = """
                The `{{ taskrun.value }}` from the `for_each` task is available only to direct child tasks \
                such as the `before_if` and the `if` tasks. To access the taskrun value of the parent task \
                in a nested child task such as the `after_if` task, use `{{ parent.taskrun.value }}`.""",
            code = """

Review comment (suggestion):
`queued` is a resererved work for an execution state that is restricted to flow-level concurrency when the behavior is QUEUE.
I'm not comptfortable to use it here as taskruns will not be queued, they would just not be created at all.

Code after:
import io.kestra.core.utils.GraphUtils;
import io.kestra.core.utils.ListUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PositiveOrZero;
import lombok.*;
import lombok.experimental.SuperBuilder;

import java.util.List;
import java.util.Optional;

@SuperBuilder
@ToString
@EqualsAndHashCode
@Getter
@NoArgsConstructor
@Schema(
    title = "Execute a group of tasks for each value in the list.",
    description = """
        You can control how many task groups are executed concurrently by setting the `concurrencyLimit` property. \

        - A `concurrencyLimit` of `0` means no limit — all task groups run in parallel. \

        - A `concurrencyLimit` of `1` means full serialization — only one task group runs at a time, in order. \

        - A `concurrencyLimit` greater than `1` allows up to that number of task groups to run in parallel. \


        Regardless of the `concurrencyLimit` property, the `tasks` will run one after the other — to run those in parallel, wrap them in a [Parallel](https://kestra.io/plugins/core/tasks/flow/io.kestra.plugin.core.flow.parallel) task as shown in the last example below (_see the flow `parallel_tasks_example`_). \


        The `values` can be defined as a JSON string or an array, e.g. a list of string values `["value1", "value2"]` or a list of key-value pairs `[{"key": "value1"}, {"key": "value2"}]`.\s


        Access the current iteration value using `{{ taskrun.value }}` \
        or `{{ parent.taskrun.value }}` when inside a nested child task. \
        The iteration number is available via `{{ taskrun.iteration }}`. \


        If you need to execute more than 2-5 tasks for each value, we recommend triggering a subflow for each value for better performance and modularity. \
        See the [flow best practices documentation](https://kestra.io/docs/best-practices/flows) for more details."""
)
@Plugin(
    examples = {
        @Example(
            full = true,
            title = """
                The `{{ taskrun.value }}` from the `for_each` task is available only to direct child tasks \
                such as the `before_if` and the `if` tasks. To access the taskrun value of the parent task \
                in a nested child task such as the `after_if` task, use `{{ parent.taskrun.value }}`.""",
            code = """