Skip to content

soql-in-loop and dml-in-loop not detected when operations are behind decisions inside loop body #305

@axan2149

Description

@axan2149

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."

Metadata

Metadata

Assignees

No one assigned

    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