-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(loops): fix loops on empty collection #3049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryFixed a critical bug where loops with empty collections (forEach with empty arrays or for loops with 0 iterations) would incorrectly execute the loop body once instead of being skipped entirely. Key Changes:
The fix ensures proper control flow by preventing the loop body from executing when the initial condition evaluation returns false (empty collection case). Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Engine as Execution Engine
participant NodeOrch as Node Orchestrator
participant LoopOrch as Loop Orchestrator
participant EdgeMgr as Edge Manager
participant DAG as DAG
Note over Engine,DAG: Loop with Empty Collection Flow
Engine->>NodeOrch: Execute loop sentinel start
NodeOrch->>LoopOrch: evaluateInitialCondition(loopId)
alt forEach with empty items
LoopOrch-->>NodeOrch: return false (skip loop)
else for with 0 iterations
LoopOrch-->>NodeOrch: return false (skip loop)
else while/doWhile
LoopOrch-->>NodeOrch: evaluate condition
end
NodeOrch-->>Engine: {sentinelStart: true, shouldExit: true, selectedRoute: LOOP_EXIT}
Engine->>EdgeMgr: getNextNodes(output)
EdgeMgr->>EdgeMgr: Activate LOOP_EXIT edge
Note over EdgeMgr: NEW: Skip node reactivation check<br/>when selectedRoute is LOOP_EXIT
EdgeMgr->>DAG: Find target via LOOP_EXIT edge
Note over DAG: Edge created only if target<br/>is outside loop (originalTarget check)
EdgeMgr-->>Engine: [nextNode outside loop]
Engine->>Engine: Continue execution after loop
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, no comments
|
@cursor review |
1 similar comment
|
@cursor review |
Summary
Type of Change
Testing
Tested with @icecrasher321
Checklist