Skip to content

[bug]: If inside a For body cannot select root-frame branch values (hang on main, KeyError with #9789) #9818

Closed

Description

@lstein

Is there an existing issue for this problem?

  • I have searched the existing issues

Version number

main at aa46003 (7.0.0-alpha.2-post), and #9789 at e27f6fd

What happened

Consider an If inside a For body whose condition is the loop item, with root-frame nodes (nodes with no loop input) on its branches. On main the session hangs right after for runs: next() returns None and is_complete() stays False. With #9789 it fails with KeyError: 'root_true' or KeyError: 'root_false' from create_for_body_iteration.

This happens for every condition sequence, including [False, False] and [True, True].

What you expected to happen

Each iteration should return the selected root value, for example ["false-root", "true-root"] for [False, True]. A root branch value should run once, and only if some iteration selects it.

How to reproduce the problem

g = Graph()
g.add_node(ForInvocation(id="for", collection=[False, True]))
g.add_node(AnyTypeTestInvocation(id="root_true", value="true-root"))
g.add_node(AnyTypeTestInvocation(id="root_false", value="false-root"))
g.add_node(IfInvocation(id="if"))
g.add_node(ForReturnInvocation(id="return"))
g.add_node(AnyTypeTestInvocation(id="after"))
g.add_edge(create_edge("for", "item", "if", "condition"))
g.add_edge(create_edge("root_true", "value", "if", "true_input"))
g.add_edge(create_edge("root_false", "value", "if", "false_input"))
g.add_edge(create_edge("if", "value", "return", "output"))
g.add_edge(create_loop_linkage("for", "return"))
g.add_edge(create_edge("for", "output_collection", "after", "value"))

Run it with the _run_graph helper from tests/app/services/shared/test_execution_engine_differential.py. The helpers come from tests/test_nodes.py.

Additional context

The For body planner creates each iteration without an admission check and expects every body input to be prepared already. A root-frame branch source is prepared only when some If execution selects it, and those executions appear one iteration at a time.

The same shape with an Iterate instead of a For works with #9789. Any fix also needs to make sure that once every iteration has resolved, an unselected root source is rejected rather than run.

Found while reviewing #9789 (follow-up to #9484).

Activity

  1. JPPhoto commented on Oct 18, 2026

    @JPPhoto
    Collaborator

    Resolved in PR #9843. The selected If branch now resolves root-frame inputs against its activation frame, including inside For bodies. Regression coverage checks mixed, all-true, and all-false conditions and confirms unselected root sources do not run.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions