[BUG][code-analyzer] sfge: calling toString() on an enum aborts the entry point (UnimplementedMethodException)

Open Beginner friendly
#2,090 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
tooling

Research direction

Start with ApexEnumValue.java around line 123 and trace the handling shown through PathScopeVisitor.java. Run the provided sf code-analyzer command against the EnumToString reproduction. Done means enum toString() no longer aborts the entry point, returns a determinate or indeterminate value as appropriate, and analysis completes without losing coverage.

Written by the indexing model from the issue text.

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

Engine: sfge (Salesforce Graph Engine) · Rule: ApexFlsViolation (DevPreview) · Selector: --rule-selector sfge

ApexEnumValue.apply implements only name(), ordinal() and (when indeterminate) equals(), then falls through to throw new UnimplementedMethodException(this, vertex) at ApexEnumValue.java:123.

toString() is universal in Apex — every enum inherits it — so any path that calls it on an enum value aborts.

Schema.DisplayType dt = Account.Name.getDescribe().getType();
a.Description = dt.toString();
Output / Logs
UnimplementedMethodException: ApexEnumValue:toString, vertex=MethodCallExpressionVertex{fullMethodName=dt.toString, ...}:
com.salesforce.graph.symbols.apex.ApexEnumValue.apply(ApexEnumValue.java:123);
com.salesforce.graph.symbols.PathScopeVisitor.handleApexValueMethod(PathScopeVisitor.java:1487);
com.salesforce.graph.symbols.PathScopeVisitor.afterVisit(PathScopeVisitor.java:1242); ...
Steps To Reproduce
  1. Create an empty SFDX project (sfdx-project.json with a single force-app package directory).
  2. Add force-app/main/default/classes/EnumToString.cls with the class shown below, plus a standard EnumToString.cls-meta.xml (apiVersion 62.0).
  3. Add code-analyzer.yml:
    engines:
      sfge:
        java_thread_timeout: 900000
        java_thread_count: 4
    
  4. Run:
    sf code-analyzer run --rule-selector sfge --workspace . --config-file code-analyzer.yml
    
  5. The run reports an InternalExecutionError for the entry point instead of analysing it. That entry point yields no ApexFlsViolation findings at all, and nothing in the summary indicates coverage was lost.
public with sharing class EnumToString {
    @AuraEnabled
    public static void run() {
        Schema.DisplayType dt = Account.Name.getDescribe().getType();
        Account a = new Account();
        a.Description = dt.toString();
        insert a;
    }
}
Expected Behavior

toString() on an enum should resolve like name() does — returning the value name when determinate, and an indeterminate string otherwise. Suggested fix: handle toString alongside METHOD_NAME in ApexEnumValue.apply, and add it to INDETERMINANT_VALUE_PROVIDERS.

More generally, an unmodelled method on a known value type should degrade to an indeterminate value rather than abort the entry point.

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)

In our codebase this accounts for 8 occurrences across 4 distinct @AuraEnabled entry points — the highest count of any single unimplemented-method signature we hit.

Same class of gap as #1510, #1044 and #1003 (all on ApexStringValue), which were closed in the 2026-06-30 pre-v5 sweep.

Workaround

Replace enumValue.toString() with enumValue.name(), which sfge does model. Semantically equivalent for standard enums.

Urgency

Moderate

Dominant language
TypeScript
Stars
240
Forks
52
Avg merge
1d 23h
Merged PRs (30d)
5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from forcedotcom/code-analyzer

All issues in forcedotcom/code-analyzer

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.