Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] dfa scan triggers a InternalExecutionError - TodoException: Vertex passed in to detect schema-based validation #1463

Open
thesunlover opened this issue May 9, 2024 · 2 comments
Labels
SFGE Issues related to the Salesforce Graph Engine

Comments

@thesunlover
Copy link

scanner run dfa Issue Template

Fill out this template to submit your Code Analyzer issue.

Description:

Documentation:

Steps To Reproduce:

I'm running the sfdx scanner:run:dfa for this commit and I get the following in the sfge.log:

2024-05-09 15:40:44  ERROR ThreadableRuleExecutor:208 - Internal Error executing rule. submission=RuleRunnerSubmission{pathEntry=Method{properties={FirstChild=false, BeginLine=36, DefiningType_CaseSafe=adaptercontroller, LastChild=false, DefiningType=AdapterController, Constructor=false, EndLine=36, Name_CaseSafe=getusersettings, childIdx=4, ReturnType=UserSettingsDTO, Name=getUserSettings, Arity=1, ReturnType_CaseSafe=usersettingsdto, BeginColumn=35}}, rules=[com.salesforce.rules.AvoidDatabaseOperationInLoop@34a0683, com.salesforce.rules.AvoidMultipleMassSchemaLookups@78dc77d6, com.salesforce.rules.ApexFlsViolationRule@7a05ff78, com.salesforce.rules.PerformNullCheckOnSoqlVariables@1602f34e, com.salesforce.rules.UseWithSharingOnDatabaseOperation@452f9113, com.salesforce.rules.ApexNullPointerExceptionRule@5e563ca7]}
com.salesforce.exception.TodoException: Vertex passed in to detect schema-based validation is not a BooleanExpressionVertex, MethodCallExpressionVertex, InstanceOfExpressionVertex, LiteralExpressionVertex, or VariableExpressionVertex: parent=BooleanExpression{properties={FirstChild=true, Operator=&&, BeginLine=79, DefiningType_CaseSafe=usersettingsdto, LastChild=true, DefiningType=UserSettingsDTO, EndLine=79, childIdx=0, BeginColumn=13}}, vertex=CastExpression{properties={FirstChild=false, BeginLine=79, DefiningType_CaseSafe=usersettingsdto, LastChild=true, DefiningType=UserSettingsDTO, TypeRef=Boolean, EndLine=79, childIdx=1, BeginColumn=40}}
	at com.salesforce.rules.fls.apex.operations.SchemaBasedValidationAnalyzer.checkForValidation(SchemaBasedValidationAnalyzer.java:52) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.rules.fls.apex.operations.FlsValidationCentral.checkSchemaBasedFlsValidation(FlsValidationCentral.java:71) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.rules.fls.apex.AbstractFlsVisitor.afterVisit(AbstractFlsVisitor.java:80) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.rules.fls.apex.ReadFlsRuleVisitor.afterVisit(ReadFlsRuleVisitor.java:61) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.vertex.StandardConditionVertex$Positive.afterVisit(StandardConditionVertex.java:108) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:273) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:189) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:184) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:264) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:231) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:189) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:184) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:264) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:231) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:231) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:189) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:184) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:264) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:231) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:231) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:189) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.visit(ApexPathWalker.java:184) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.walk(ApexPathWalker.java:172) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.walkPath(ApexPathWalker.java:124) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.walkPath(ApexPathWalker.java:105) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.graph.visitor.ApexPathWalker.walkPath(ApexPathWalker.java:88) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.rules.ApexFlsReadRuleHandler.detectViolations(ApexFlsReadRuleHandler.java:37) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.rules.ApexFlsViolationRule.lambda$_run$0(ApexFlsViolationRule.java:91) ~[sfge-1.0.1-pilot.jar:?]
	at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422) ~[guava-31.1-jre.jar:?]
	at com.salesforce.rules.ApexFlsViolationRule._run(ApexFlsViolationRule.java:88) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.rules.AbstractPathTraversalRule.run(AbstractPathTraversalRule.java:15) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.rules.PathBasedRuleRunner.executeRulesOnPaths(PathBasedRuleRunner.java:144) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.rules.PathBasedRuleRunner.runRules(PathBasedRuleRunner.java:81) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.rules.ThreadableRuleExecutor$CallableExecutor.runRules(ThreadableRuleExecutor.java:230) ~[sfge-1.0.1-pilot.jar:?]
	at com.salesforce.rules.ThreadableRuleExecutor$CallableExecutor.call(ThreadableRuleExecutor.java:167) [sfge-1.0.1-pilot.jar:?]
	at com.salesforce.rules.ThreadableRuleExecutor$CallableExecutor.call(ThreadableRuleExecutor.java:127) [sfge-1.0.1-pilot.jar:?]
	at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1448) [?:?]
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) [?:?]
	at java.util.concurrent.ForkJoinTask.doInvoke(ForkJoinTask.java:408) [?:?]
	at java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:736) [?:?]
	at java.util.concurrent.ForkJoinTask$AdaptedCallable.run(ForkJoinTask.java:1456) [?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426) [?:?]
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) [?:?]
	at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) [?:?]
	at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) [?:?]
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) [?:?]
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) [?:?]
2024-05-09 15:40:44  INFO  ThreadableRuleExecutor:216 - Finished. method=AdapterController:getUserSettings:36

Expected Behavior:

Give a meaningful error in the output.
Screenshots:

Desktop:

  • Operating System: Windows 11
  • Code Analyzer version: @salesforce/sfdx-scanner (4.0.0)
  • Salesforce CLI version: @salesforce/cli/2.38.7 win32-x64 node-v18.13.0

Additional Context:

Workaround:

N/A

Urgency:

It is for a 2GP managed package.

@jfeingold35
Copy link
Collaborator

@thesunlover , the link you provided isn't working. Can you provide sample code? What's happening at line 79 of UserSettingsDTO?

@thesunlover
Copy link
Author

thesunlover commented May 10, 2024

Hey @jfeingold35, thank you!

Here is the helper function containing the code around line 79 of UserSettingsDTO:

    /**
     * @description Setup Features
     * @param userId Id of the User
     */
    private void setupFeatures(Id userId) {
        this.features.add(Constants.BASIC_FEATURE_TYPE);
        Features__c settings = Features__c.getInstance(userId);
        Features__c defaults = Features__c.getOrgDefaults();              

        Object feature1 = settings.get('Enable_Feature1__c'); // checkbox field
        if (feature1 == null) {
            feature1 = defaults.get('Enable_Feature1__c');
        }
        if (feature1 != null && (Boolean)feature1) {
            this.features.add(Constants.FEATURE1_TYPE);
        }                
        Object feature2 = settings.get('Enable_Feature2__c'); // checkbox field
        if (feature2 == null) {
            feature2 = defaults.get('Enable_Feature2__c');
        }
        if (feature2 != null && (Boolean)feature2) { //line 79
            this.features.add(Constants.FEATURE2_TYPE);
        }
    }
           

@stephen-carter-at-sf stephen-carter-at-sf added the SFGE Issues related to the Salesforce Graph Engine label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SFGE Issues related to the Salesforce Graph Engine
Projects
None yet
Development

No branches or pull requests

3 participants