[BUG][code-analyzer] Flow rules producing false positives and flagging platform limitations (MissingFaultHandler, MissingDescription, UnusedResource, SameRecordUpdate)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- typescript
- Lĩnh vực
- tooling
Hướng nghiên cứu
Tái hiện bốn báo cáo với MyParentFlow.flow-meta.xml và MySubFlow.flow-meta.xml bằng cách sử dụng sf code-analyzer run --target "./force-app/main/default/flows" --rule-selector flow. Truy vết các điểm vào của các rule flow:MissingFaultHandler, flow:MissingDescription, flow:UnusedResource và flow:SameRecordUpdate, cùng với cách chúng xử lý các giới hạn của nền tảng và các tham chiếu tài nguyên. Hoàn thành khi các trường hợp hợp lệ không còn bị báo cáo, trong khi các vi phạm thực sự vẫn có thể được phát hiện.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
When running sf code-analyzer run --rule-selector flow on Salesforce Flow metadata, several rules are either producing false positives or flagging platform limitations that cannot be remediated:
-
flow:MissingFaultHandler — Flags subflow elements for missing fault handlers, but Flow Builder does not support adding fault paths to subflow elements (platform limitation).
-
flow:MissingDescription — Flags system-managed elements like $Record.Id (trigger record references) for missing descriptions, but these elements cannot have custom descriptions added (platform limitation).
-
flow:UnusedResource — Flags resources (e.g., formula variables) as unused when they are actively being used in the flow (false positive). The analyzer appears to not detect usage in certain contexts such as decision conditions or formula expressions.
-
flow:SameRecordUpdate — Flags AfterSave record triggers for modifying the same record. This is a valid business requirement when email alerts (only supported in AfterSave flows) must be sent before updating the record. The logic cannot be moved to BeforeSave without losing functionality.
Output / Logs
# Severity Rule Location Message
1 2 (High) flow:MissingFaultHandler MyParentFlow.flow-meta.xml:140:1 An element that can fire fault events is missing fault handlers. Add fault handlers to all Create Records, Update Records, Delete Records, Action Calls, and Subflows.
2 2 (High) flow:MissingFaultHandler MySubFlow.flow-meta.xml:140:1 An element that can fire fault events is missing fault handlers. Add fault handlers to all Create Records, Update Records, Delete Records, Action Calls, and Subflows.
3 3 (Moderate) flow:UnusedResource MyParentFlow.flow-meta.xml:76:1 A resource is not used elsewhere in the flow. Check that you did not intend to use the resource and then delete it.
4 3 (Moderate) flow:SameRecordUpdate MyParentFlow.flow-meta.xml:103:1 An AfterSave record trigger is modifying the same record. Record modifications should be done in BeforeSave triggers, not AfterSave triggers. The trigger definition may be in a parent flow that calls the current flow as a subflow, passing in the recordId of the trigger record.
5 4 (Low) flow:MissingDescription MyParentFlow.flow-meta.xml:18:1 An element contains a label that is missing a description. Document all elements with labels to make the flow comprehensible to future maintainers.
6 4 (Low) flow:MissingDescription MyParentFlow.flow-meta.xml:150:1 An element contains a label that is missing a description. Document all elements with labels to make the flow comprehensible to future maintainers.
7 4 (Low) flow:MissingDescription MySubFlow.flow-meta.xml:2:1 An element contains a label that is missing a description. Document all elements with labels to make the flow comprehensible to future maintainers.
8 4 (Low) flow:MissingDescription MySubFlow.flow-meta.xml:2:1 An element contains a label that is missing a description. Document all elements with labels to make the flow comprehensible to future maintainers.
9 4 (Low) flow:MissingDescription MySubFlow.flow-meta.xml:49:1 An element contains a label that is missing a description. Document all elements with labels to make the flow comprehensible to future maintainers.
10 4 (Low) flow:MissingDescription MySubFlow.flow-meta.xml:49:1 An element contains a label that is missing a description. Document all elements with labels to make the flow comprehensible to future maintainers.
Steps To Reproduce
Create a Salesforce Flow metadata file with the following characteristics:
- MyParentFlow.flow-meta.xml (AfterSave record-triggered flow on Account object)
- Contains a subflow element (InvokeMySubflow)
- Contains a formula variable (formulavar) used in a decision condition
- Contains an email alert action followed by a record update on the same triggering record
- MySubFlow.flow-meta.xml (Auto-launched flow)
- Contains an assignment element and variables
-
Run the command:sf code-analyzer run --target "./force-app/main/default/flows" --rule-selector flow
-
Observe the violations listed above.
Attached Files:
MyParentFlow.flow-meta.xml
MySubFlow.flow-meta.xml
Expected Behavior
- flow:MissingFaultHandler — Should not flag subflow elements, as fault paths cannot be added to subflows in Flow Builder (platform limitation).
- flow:MissingDescription — Should not flag system-managed elements like $Record.Id, as these cannot have custom descriptions (platform limitation).
- flow:UnusedResource — Should correctly detect when a resource (like formulavar) is used in decision conditions and not flag it as unused.
- flow:SameRecordUpdate — Should support exceptions or provide guidance for valid business cases where AfterSave record updates are required (e.g., when email alerts must be sent before updating the record).
Operating System
macOS
Salesforce CLI Version
@salesforce/cli/2.130.9 darwin-arm64 node-v22.22.2
Code Analyzer Plugin (code-analyzer) Version
code-analyzer 5.11.1
Node Version
v24.14.0
Java Version
openjdk version "21.0.2" 2024-01-16 LTS OpenJDK Runtime Environment Zulu21.32+17-CA (build 21.0.2+13-LTS) OpenJDK 64-Bit Server VM Zulu21.32+17-CA (build 21.0.2+13-LTS, mixed mode, sharing)
Python Version
command not found: python
Additional Context (Screenshots, Files, etc)
Workaround
- Currently using the Suppress Violations feature to suppress false positives (flow:UnusedResource, flow:MissingDescription) by adding @suppress in the tags of flow elements.
- However, this is a temporary workaround and does not address the underlying false positive detection or platform limitation issues.
Urgency
Moderate
- Ngôn ngữ chính
- TypeScript
- Star
- 241
- Fork
- 51
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của forcedotcom/code-analyzer
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
forcedotcom/code-analyzer#2094 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
forcedotcom/code-analyzer#2093 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
forcedotcom/code-analyzer#2091 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
forcedotcom/code-analyzer#2090 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
forcedotcom/code-analyzer#2104 ·
Tất cả issue của forcedotcom/code-analyzer
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
apache/rocketmq-dashboard#6610 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
nextjs-tracking
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
cloudflare/vinext#3920 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Team:Dashboards
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
elastic/kibana#297299 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
analytics beginner friendly community contributions-welcome good first issue hacktoberfest help wanted up-for-grabs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
affected/v17 affected/v18 area/frontend type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
umbraco/Umbraco-CMS#24186 ·
Maintainer thường phản hồi trong vòng 2 ngày