Description
The soql-in-loop rule does not flag recordLookups elements that are reachable from a loop's nextValueConnector when there are intervening decision or assignment elements in the connector chain. The same likely applies to dml-in-loop.
Steps to Reproduce
Given a flow with this connector chain inside a loop:
loop (nextValueConnector)
→ recordLookups (get_SOPROD)
→ recordLookups (get_DestIcitem)
→ recordLookups (get_SourceIcitem)
→ decision (decision_source_found)
→ recordLookups (get_SourceIclocitem)
→ decision (decision_stock_found)
→ assignment (assign_build_sydatat)
→ assignment (assign_add_to_collection)
→ loop (back to loop_selected_lines)
Running sf flow scan --files <path> produces no soql-in-loop violations, even though there are 4 recordLookups elements executing inside the loop body on every iteration.
Expected Behavior
All 4 recordLookups elements (get_SOPROD, get_DestIcitem, get_SourceIcitem, get_SourceIclocitem) should be flagged as soql-in-loop violations.
Actual Behavior
None are flagged. The scanner only appears to detect soql-in-loop when a recordLookups is the direct/immediate target of a loop's nextValueConnector without any intervening decisions.
For comparison, a different flow where the loop's nextValueConnector points directly to a recordLookups (no intervening decisions) is correctly flagged.
Environment
- CLI version:
lightning-flow-scanner@6.19.3
- OS: Windows 11
- Node: v24.14.1
Analysis
The loop-interior detection appears to only check the immediate nextValueConnector target rather than traversing the full connector chain from nextValueConnector back to the loop's noMoreValuesConnector. Any recordLookups, recordCreates, recordUpdates, or recordDeletes reachable within that chain should be considered "inside the loop."
Description
The
soql-in-looprule does not flagrecordLookupselements that are reachable from a loop'snextValueConnectorwhen there are intervening decision or assignment elements in the connector chain. The same likely applies todml-in-loop.Steps to Reproduce
Given a flow with this connector chain inside a loop:
Running
sf flow scan --files <path>produces nosoql-in-loopviolations, even though there are 4recordLookupselements executing inside the loop body on every iteration.Expected Behavior
All 4
recordLookupselements (get_SOPROD,get_DestIcitem,get_SourceIcitem,get_SourceIclocitem) should be flagged assoql-in-loopviolations.Actual Behavior
None are flagged. The scanner only appears to detect
soql-in-loopwhen arecordLookupsis the direct/immediate target of a loop'snextValueConnectorwithout any intervening decisions.For comparison, a different flow where the loop's
nextValueConnectorpoints directly to arecordLookups(no intervening decisions) is correctly flagged.Environment
lightning-flow-scanner@6.19.3Analysis
The loop-interior detection appears to only check the immediate
nextValueConnectortarget rather than traversing the full connector chain fromnextValueConnectorback to the loop'snoMoreValuesConnector. AnyrecordLookups,recordCreates,recordUpdates, orrecordDeletesreachable within that chain should be considered "inside the loop."