-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Have you tried to resolve this issue yourself first?
- I confirm I have gone through the above steps and still have an issue to report.
Bug Description
The flow:DbInLoop rule appears to be firing on flows that contain a loop and a database operation (DML, SOQL), even when those operations are processed outside of the loop. For example: Address_After_Update_Stamp_Address_on_Quote.flow-meta.xml
Result:
1 2 (High) flow:DbInLoop Address_After_Update_Stamp_Address_on_Quote.flow-meta.xml:291:1 A Database operation (RecordLookups, RecordCreates, RecordUpdates, RecordDeletes) is being performed within a loop. To avoid excessive Database calls, the operation should be bulkified by using collection variables and the 'IN' operator.Output / Logs
jsiders@jsiders-mac salesforce % sf code-analyzer run -t force-app/main/default/flows/Address_After_Update_Stamp_Address_on_Quote.flow-meta.xml
Streaming logs in real time to:
/var/folders/8d/0t7sckgj10xcb32zycf088480000gp/T/sfca-2025_12_09_14_50_27_060.log
Selecting rules... done.
Executing rules... done. Executed rules from pmd, regex, flow.
Violation file paths relative to '/Users/jsiders/Documents/VSCode/Nasuni/salesforce/force-app/main/default/flows'.
# Severity Rule Location Message
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 2 (High) flow:DbInLoop Address_After_Update_Stamp_Address_on_Quote.flow-meta.xml:291:1 A Database operation (RecordLookups, RecordCreates, RecordUpdates, RecordDeletes) is being performed within a loop. To avoid excessive Database calls, the operation should be bulkified by using collection variables and the 'IN' operator.Steps To Reproduce
- Download and add this file to your project: Address_After_Update_Stamp_Address_on_Quote.flow-meta.xml
- Run
sf code-analyzer run -t {{your_local_file_path}}
Expected Behavior
This violation should only fire when a DML or SOQL operation is performed inside of the loop element. Database operations performed outside of the loop element should not trigger this violation.
Operating System
macOS Tahoe 26.0
Salesforce CLI Version
@salesforce/cli/2.113.6 darwin-arm64 node-v22.20.0
Code Analyzer Plugin (code-analyzer) Version
5.7.0 (also an issue on 5.7.1)
Node Version
v22.20.0
Java Version
openjdk version "17.0.13" 2024-10-15 OpenJDK Runtime Environment Homebrew (build 17.0.13+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.13+0, mixed mode, sharing)
Python Version
Python 3.13.1
Additional Context (Screenshots, Files, etc)
No response
Workaround
Two workarounds, neither of which are ideal:
- Replacing the loop with a Transform element clears the issue. This is sufficient for relatively simple transformation logic, but there are some times when more complex logic is awkward or impossible to handle in this manner.
- Manually overriding the severity of the rule, which renders the rule more or less useless as an actual defensive check.
Urgency
Moderate