You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stateful operator upstream of a Loop Start silently overwrites loop variables #7248
A Loop Start MERGES any unstamped, counter-0 State it receives into its loop variables (LoopStartOperator.process_state → self.state.update(state)). That merge is load-bearing: the back-edge writes the next iteration's variables to the Loop Start's own input-port state URI with the same "no loop" envelope (_jump_to_loop_start → State.to_tuple(0)), so the runtime cannot distinguish the loop's own state from someone else's.
The side effect is that any operator emitting boundary state via the public produce_state_on_start / produce_state_on_finish API, upstream of or inside a loop containing a Loop Start, silently injects its keys into that loop's variables:
Emitted key
Effect
collides with a loop variable (e.g. the default i)
silently overwrites loop control — wrong iteration count, no error
table
aborts the loop with _reserved_name_error at produce_state_on_finish
operator.py's self.state.update(state) dates to #5700. It is not created by #6913, but #6913 makes operator-originated boundary state a first-class flow through loops (the Scala side now emits it with an explicit envelope), so the hazard is easier to reach.
Raised by @Xiao-zhen-Liu in review on #6913 (#discussion_r3696858248). The Loop Start side is now documented and pinned there (test_loopstart_merges_unstamped_state_instead_of_forwarding_it), but the collision itself is undefended.
Note the Loop End side is NOT affected: its inbound loop state is always stamped by the matching Loop Start, so it can tell the two apart and forwards a body operator's boundary state instead of consuming it.
Possible directions
Namespace the loop's own variables on the envelope (a producer tag on StateFrame) so a Loop Start can tell its own state from an upstream operator's, and reject/ignore the latter.
Reject a merge that would overwrite an existing loop variable, with a message naming the colliding key.
Document it as the contract and add an e2e for Source → statefulOp → LoopStart.
It looks like the issue description doesn't quite follow our template yet:
This issue doesn't appear to use one of our templates (Bug, Feature, or Task). Please open it using a template so the required details are captured.
Filling out the template helps reviewers understand and triage your contribution faster. Please edit the description to complete it. This message will disappear automatically once the template is followed.
You can find the template prompts by editing the description, or see CONTRIBUTING.md for the full contribution flow.
Activity
github-actions commentedon Aug 2, 2026
👋 Thanks for opening this issue, @aglinxinyuan!
It looks like the issue description doesn't quite follow our template yet:
Filling out the template helps reviewers understand and triage your contribution faster. Please edit the description to complete it. This message will disappear automatically once the template is followed.
You can find the template prompts by editing the description, or see CONTRIBUTING.md for the full contribution flow.
fix(amber): pass unstamped boundary states through LoopEnd instead of…
VuMartin commentedon Aug 28, 2026
/take