[BUG][code-analyzer] sfge: indexing a value the engine cannot resolve aborts the entry point instead of degrading
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 72/100
調査の方向性
まず PathScopeVisitor.java の 804-806 行付近と 874-902 行を確認し、次に他の不確定な値について ApexMapValue.java:183-191 と JSONDeserializeFactory.java:78-79 を調べます。提供された sf code-analyzer コマンドと Apex クラスで問題を再現します。不確定な値がインデックス化されたときに 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
An array/index load whose target resolves to an indeterminate ApexSingleValue aborts path evaluation — in a method that already returns an indeterminate value for every other input.
List<String> parts = (List<String>) byKey.get('k'); // byKey is Map<String, Object>
String first = parts[0];
ApexMapValue.apply takes the indeterminate branch of METHOD_GET (ApexMapValue.java:183-191) and returns a bare indeterminate value typed from the map's declared value type. Because that type is Object, build() yields an ApexSingleValue rather than an ApexListValue, and indexing it hits the unhandled else at PathScopeVisitor.java:894. The Apex cast to List<String> does not help — the engine keeps the map's declared value type. JSONDeserializeFactory.java:78-79 builds the same shape for types it declines to model, so this is not the only route in.
The fix already exists in the same method:
// PathScopeVisitor.java:874-902
private ApexValue<?> getIndeterminantArrayLoadValue(@Nullable ApexValue<?> apexValue) {
final Typeable listType;
if (apexValue instanceof ApexListValue) { ...
} else if (apexValue instanceof ApexForLoopValue) { ...
} else if (apexValue instanceof ApexSoqlValue) { ...
} else if (apexValue == null) {
listType = null; // <-- null is fine
} else {
throw new UnexpectedException(apexValue); // <-- everything else aborts
}
ApexValueBuilder builder = ApexValueBuilder.get(this).withStatus(ValueStatus.INDETERMINANT);
if (listType != null) {
return builder.declarationVertex(listType).build();
} else {
return builder.buildUnknownType(); // <-- the null branch lands here
}
}
A null apexValue — strictly less information than an indeterminate ApexSingleValue — falls through to buildUnknownType().
Output / Logs
UnexpectedException: ApexValue(ApexSingleValue) {status=INDETERMINANT, declarationVertex=SyntheticTypedVertex@...,
valueVertex=null, returnedFrom=ApexValue(ApexMapValue) {status=INDETERMINANT,
declarationVertex=Parameter{... Type=Map<String,Object> ... Name=byKey}} ...}
at com.salesforce.graph.symbols.PathScopeVisitor.getIndeterminantArrayLoadValue(PathScopeVisitor.java:894)
at com.salesforce.graph.symbols.PathScopeVisitor.afterVisit(PathScopeVisitor.java:810)
at com.salesforce.graph.symbols.DefaultSymbolProviderVertexVisitor.afterVisit(DefaultSymbolProviderVertexVisitor.java:737)
at com.salesforce.graph.vertex.ArrayLoadExpressionVertex.afterVisit(ArrayLoadExpressionVertex.java:58)
Steps To Reproduce
- Create an empty SFDX project (
sfdx-project.jsonwith a singleforce-apppackage directory). - Add
force-app/main/default/classes/IndeterminateMapGetIndex.clswith the class shown below, plus a standardIndeterminateMapGetIndex.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. That entry point yields noApexFlsViolationfindings at all, and nothing in the summary indicates coverage was lost.
public with sharing class IndeterminateMapGetIndex {
@AuraEnabled
public static void run(Map<String, Object> byKey) {
List<String> parts = (List<String>) byKey.get('k');
String first = parts[0];
Account a = new Account();
a.Name = first;
insert a;
}
}
Expected Behavior
Routing the else to listType = null would make the unknown case behave like the already-unknown case, which is what the method's name and Javadoc promise ("Generates a single indeterminant value based on the type contained in apexValue").
The caller has the same gap: PathScopeVisitor.java:804-806 carries a matching bare throw new UnexpectedException(vertex) on its own else.
Operating System
macOS 26.5.2
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)
Map<String, Object> is the standard way to accept a loosely typed payload in an @AuraEnabled method, and indexing a list pulled out of one is routine.
Costs three @AuraEnabled entry points in our codebase via two different routes — the map shape above, and a static initializer in a shared constants class that indexes a String.split() result. The second is the worse pattern: because it sits in a constants class, every entry point that touches it inherits the abort.
Workaround
Assign through an intermediate typed local that sfge can resolve, or avoid indexing values pulled out of an Object-valued map on paths that reach DML. Neither is dependable.
Urgency
Moderate
- 主要言語
- TypeScript
- スター
- 240
- フォーク
- 52
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 5
コントリビューションガイド
はじめの一歩
- 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 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
forcedotcom/code-analyzer#2098 ·
forcedotcom/code-analyzer の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
calcite-components needs triage refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Esri/calcite-design-system#15203 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
danielmiessler/LifeOS#2218 ·