[BUG][code-analyzer] sfge: passing a boolean expression (==, &&) directly to an Apex method aborts the entry point
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 63/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java, typescript
- 領域
- backend, testing-qa
調査の方向性
Start with MethodTypeMatchUtil.java, especially parameterTypesMatch and getTypeFromSymbol, then inspect how BooleanExpressionVertex is represented and tested. Reproduce with the provided Apex class and sfge command; verify the entry point is analysed and the expected ApexFlsViolation on the insert is reported without an InternalExecutionError.
索引モデルが issue の本文から書いたものです。
説明
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
Engine: sfge (Salesforce Graph Engine) · Rule: ApexFlsViolation (DevPreview) · Selector: --rule-selector sfge
To pick the method a call resolves to, MethodTypeMatchUtil.parameterTypesMatch types each argument. It handles null literals, new collections, variables, SOQL, invocables, BinaryExpressionVertex and Typeable, and sends anything else to getTypeFromSymbol. That method throws when the argument has no symbolic name:
// MethodTypeMatchUtil.java:165-168
String symbolicName = invokedParameter.getSymbolicName().orElse(null);
if (symbolicName == null) {
throw new UnexpectedException(invokedParameter);
}
A BooleanExpressionVertex (a == b, a != b, a && b, a || b) is neither a BinaryExpressionVertex nor Typeable and has no symbolic name, so any call that passes one straight to a method declared on an Apex class aborts the entry point.
b.put('isDefault', name == 'Default');
Standard-library methods are not affected, since sfge models them on the value and never runs the type match: Map<String, Object>.put('k', a != null && a == 'x') is analysed normally.
Output / Logs
UnexpectedException: BooleanExpression{properties={FirstChild=false, Operator===, BeginLine=10, DefiningType=BooleanArgToUserMethod, EndLine=10, childIdx=2, BeginColumn=28}}:
com.salesforce.graph.ops.MethodTypeMatchUtil.getTypeFromSymbol(MethodTypeMatchUtil.java:167);
com.salesforce.graph.ops.MethodTypeMatchUtil.parameterTypesMatch(MethodTypeMatchUtil.java:150);
com.salesforce.graph.ops.MethodUtil.getInvoked(MethodUtil.java:358);
com.salesforce.graph.ops.MethodUtil.getInvoked(MethodUtil.java:158);
com.salesforce.graph.ops.MethodUtil.getPaths(MethodUtil.java:626);
com.salesforce.graph.ops.expander.ApexPathExpander.resolveMethodCall(ApexPathExpander.java:849)
Steps To Reproduce
- Create an empty SFDX project (
sfdx-project.jsonwith a singleforce-apppackage directory). - Add
force-app/main/default/classes/BooleanArgToUserMethod.clswith the class shown below, plus a standardBooleanArgToUserMethod.cls-meta.xml(apiVersion 62.0). - Add
code-analyzer.yml:engines: sfge: java_thread_timeout: 900000 java_thread_count: 4 - Run:
sf code-analyzer run --rule-selector sfge --workspace . --config-file code-analyzer.yml - The run reports an
InternalExecutionErrorfor the entry point instead of analysing it. Theinsertgoes unreported: the entry point yields noApexFlsViolationat all, and nothing in the summary indicates coverage was lost.
public with sharing class BooleanArgToUserMethod {
public class Bag {
public void put(String key, Object value) {
}
}
@AuraEnabled
public static void run(String name) {
Bag b = new Bag();
b.put('isDefault', name == 'Default');
insert new Account(Name = name);
}
}
Expected Behavior
A boolean expression is a Boolean, and it should match a Boolean or Object parameter. Suggested fix: type BooleanExpressionVertex as Boolean in parameterTypesMatch, next to the BinaryExpressionVertex branch, or make it Typeable.
More generally, an argument the matcher cannot type should count as an unknown match rather than abort the entry point.
Operating System
macOS 26.7.1
Salesforce CLI Version
@salesforce/cli/2.147.7 darwin-arm64 node-v24.5.0
Code Analyzer Plugin (code-analyzer) Version
code-analyzer 5.15.0
Node Version
v24.5.0
Java Version
openjdk version "11.0.32" 2026-07-21
Python Version
N/A
Additional Context (Screenshots, Files, etc)
Also fails on code-analyzer 5.16.0 (sfge 0.25.0) under OpenJDK 21 on ubuntu-latest, with the same stack. In our codebase it abandons 3 @AuraEnabled entry points, all of them building a response with put(key, <comparison>).
A control in the same workspace, with the argument assigned to a local first (Boolean isDefault = name == 'Default'; b.put('isDefault', isDefault);), was analysed normally and reports the expected ApexFlsViolation on the insert.
The identical stack was reported in #1497 ("We received 6 of these, all with identical error and stack"), the consolidation issue closed in the 2026-06-30 pre-v5 sweep. That comment got no reply, and the bug has no issue of its own.
Workaround
Assign the expression to a local Boolean and pass the variable.
Urgency
Moderate
- 主要言語
- TypeScript
- スター
- 241
- フォーク
- 51
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
forcedotcom/code-analyzer のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
forcedotcom/code-analyzer#2094 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
forcedotcom/code-analyzer#2093 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
forcedotcom/code-analyzer#2091 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
forcedotcom/code-analyzer#2090 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
forcedotcom/code-analyzer#2104 ·
forcedotcom/code-analyzer の issue をすべて見る
似ている issue
-
bug go
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
genkit-ai/genkit#6761 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NousResearch/hermes-agent#136483 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
facioquo/stock-indicators-dotnet#2316 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
vercel-labs/skills#2460 ·
メンテナーはふだん 1 日以内に返信