Skip to content

Flattened Iteration output breaks List Operator when one round returns an empty array #459

In review

Description

@WH-2099

With output flattening enabled, an Iteration that returns [] in one round and ["ok"] in another produces the right value with the wrong type.
The downstream List Operator rejects the nonempty array[any] and the workflow fails.

Reproduction

  1. Set the Iteration input to [[], ["ok"]], use its current item as the output, and enable flattening.
  2. Connect the Iteration output to a List Operator with its default settings.
  3. Run the workflow. The List Operator reports that it received an ArrayAnyVariable.

The same failure occurs with the empty round last and with numeric input such as [[2, 1], []].
Reproduced on Graphon main at 5d00f29.

Expected behavior

The List Operator should receive ["ok"] as array[string] or [2, 1] as array[number].
An empty array[any] supplies no element type. Other arrays can still supply one, including explicitly typed empty arrays.
If every round returns an untyped empty array, the result should remain an empty array[any].

Follow-up to #344. Reported in langgenius/dify#47571, item 12.

Activity

  1. self-assigned this
    on Dec 4, 2026
  2. dosubot commented on Dec 4, 2026

    @dosubot

    The fix belongs in Iteration’s _collect_iteration_outputs. It flattens the values correctly, but counts every array’s type tag when deciding which type to keep. I’d skip only empty ArrayAnySegment instances in that vote and copy the type from the first remaining array if the remaining tags agree. Keep the ArrayAnySegment fallback when no arrays vote or the tags disagree. Don’t re-infer from the flattened values: the existing declared-any and mixed-types tests protect nonempty array[any] and conflicting typed empties, respectively. [1] [2]

    test_iteration_preserves_array_output_types already asserts both the runtime type and the final value, so it’s a good place for the new cases. In a downstream List Operator regression, include a nonempty result: the operator returns success for empty input before checking the type, so an all-empty case alone won’t catch this bug. [3] [4] [5]

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about graphon with Dosu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions