[BUG][code-analyzer] The engine with name 'sfge' threw an unexpected error
还没有人认领这个 Issue。
评估
调研方向
使用 code-analyzer-sfge.yml、code-scan-sfge.csv 和提供的 CLI 命令重现失败,然后检查 GremlinUtil.java 和 MethodPathBuilderVisitor.java,尤其是 visitForEachStatement。比较对失败的 null 合并表达式与可正常工作的变通方案所进行的 AST 处理。完成标准是:有效的 Apex 不再导致意外的图加载异常,并且该情况有覆盖率。
由索引模型根据 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
When running the SFGE engine using
sfca-2025_12_30_15_43_01_855.log
Related log specific for SFGE is below, which suggests that the following code is an issue
for (Contact c : cList ?? new List<Contact>()) {}
Specifically i think it is the ?? within the for loop, since moving it out seems to stop this error happening.
Overall, it seems to be two things
- Massive failures which make no sense unless really digging into issues
- Issue with parsing (the AST tree?) to Apex class for something which is valid apex
Output / Logs
2025-12-30 15:44:44 ERROR Sfge:159 - Unexpected exception while loading graph
com.salesforce.exception.UnexpectedException: vp[FirstChild->false], vp[BeginLine->313], vp[DefiningType_CaseSafe->APEXCLASSWITHISSUE...], vp[LastChild->false], vp[DefiningType->APEXCLASSWITHISSUE...], vp[EndLine->313], vp[childIdx->3], vp[BeginColumn->3]
at com.salesforce.graph.build.GremlinUtil.getChildren(GremlinUtil.java:60)
at com.salesforce.graph.build.MethodPathBuilderVisitor.visitForEachStatement(MethodPathBuilderVisitor.java:235)
at com.salesforce.graph.build.MethodPathBuilderVisitor._visit(MethodPathBuilderVisitor.java:130)
at com.salesforce.graph.build.MethodPathBuilderVisitor._visit(MethodPathBuilderVisitor.java:159)
at com.salesforce.graph.build.MethodPathBuilderVisitor.apply(MethodPathBuilderVisitor.java:97)
at com.salesforce.graph.build.AbstractApexVertexBuilder.afterInsert(AbstractApexVertexBuilder.java:169)
at com.salesforce.graph.build.AbstractApexVertexBuilder.buildVertices(AbstractApexVertexBuilder.java:153)
at com.salesforce.graph.build.AbstractApexVertexBuilder.buildVertices(AbstractApexVertexBuilder.java:125)
at com.salesforce.graph.build.AbstractApexVertexBuilder.buildVertices(AbstractApexVertexBuilder.java:35)
at com.salesforce.graph.build.CustomerApexVertexBuilder.build(CustomerApexVertexBuilder.java:21)
at com.salesforce.graph.build.Util.buildGraph(Util.java:39)
at com.salesforce.graph.ops.GraphUtil.loadSourceFilesAndFolders(GraphUtil.java:170)
at com.salesforce.Sfge$Dependencies.loadSourceFilesAndFoldersToGraph(Sfge.java:249)
at com.salesforce.Sfge.execute(Sfge.java:153)
at com.salesforce.Sfge.process(Sfge.java:103)
at com.salesforce.Sfge.main(Sfge.java:71)
Steps To Reproduce
sf code-analyzer run --config-file ./code-analyzer-sfge.yml --view detail -f codescan/code-scan-sfge.csv -r sfge -t app\classes\class.cls
Expected Behavior
If failing, then fail with a meaningful error, but in this case I don't believe an error is correct
Operating System
Windows 11
Salesforce CLI Version
@salesforce/cli/2.116.6 win32-x64 node-v24.8.0
Code Analyzer Plugin (code-analyzer) Version
code-analyzer 5.7.1 (5.7.1)
Node Version
v24.8.0
Java Version
openjdk version 21.0.8
Python Version
Python 3.13.7
Additional Context (Screenshots, Files, etc)
No response
Workaround
No response
Urgency
Low
- 主要语言
- TypeScript
- 星标
- 240
- 派生
- 52
- 平均合并
- 9 小时 48 分钟
- 30 天内合并 PR
- 3
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 天 新手友好度 45/100
forcedotcom/code-analyzer#2099 ·
查看 forcedotcom/code-analyzer 的全部 Issue
相似的 Issue
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
-
Crush 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
catppuccin/catppuccin#3125 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
ElementsProject/cln-application#167 · 1 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Quantco/pnpm-licenses#17 ·
-
难度 2/5 1-3 小时 新手友好度 75/100