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] InternalExecutionError #1028

Closed
az-oolloow opened this issue Mar 20, 2023 · 5 comments
Closed

[BUG] InternalExecutionError #1028

az-oolloow opened this issue Mar 20, 2023 · 5 comments
Labels
BUG P3 Rarely Malfunction duplicate This issue or pull request already exists SFGE Issues related to the Salesforce Graph Engine

Comments

@az-oolloow
Copy link

We got this error asking us to raise it on Github

Graph Engine identified your source and sink, but you must manually verify that you have a sanitizer in this path. Then, add an engine directive to skip the path. Next, create a Github issue for the Code Analyzer team that includes the error and stack trace. After we fix this issue, check the Code Analyzer release notes for more info. Error and stacktrace: TodoException: What should I do if ApexValue from StandardCondition is not an ApexBooleanValue, ApexCustomValue, ApexForLoopValue, or ApexSingleValue: ApexValue=ApexValue(ApexSoqlValue) {status=INITIALIZED, declarationVertex=null, valueVertex=SoqlExpression{properties={FirstChild=true, BeginLine=1304, DefiningType_CaseSafe=accountproductlinkcontroller, LastChild=false, Query=[SELECT Id, Name, All_Accounts__c, Excludes_Account__c, Filters_Account__c, Includes_Account__c, Priority__c, End_Date__c
                                   FROM Survey__c
                                   WHERE Valid_For_Sync__c = TRUE
                                                             LIMIT 24999], DefiningType=AccountProductLinkController, EndLine=1307, childIdx=0, BeginColumn=35}}, resolvedValues={}, returnedFrom=null, invocableExpression=null, method=null}, parent=BooleanExpression{properties={FirstChild=true, Operator=&&, BeginLine=1310, DefiningType_CaseSafe=accountproductlinkcontroller, LastChild=true, DefiningType=AccountProductLinkController, EndLine=1310, childIdx=0, BeginColumn=17}}, vertex=MethodCallExpressionVertex{fullMethodName=survey.Excludes_Account__c.contains, referenceVertex=LazyVertex{result=ReferenceExpression{properties={FirstChild=true, Names=[survey, Excludes_Account__c], BeginLine=1310, DefiningType_CaseSafe=accountproductlinkcontroller, LastChild=false, DefiningType=AccountProductLinkController, EndLine=1310, Name_CaseSafe=survey.excludes_account__c, childIdx=0, BeginColumn=55, ReferenceType=METHOD, Name=survey.Excludes_Account__c}}}, chainedNames=[survey, Excludes_Account__c], properties={FirstChild=false, FullMethodName=survey.Excludes_Account__c.contains, BeginLine=1310, FullMethodName_CaseSafe=survey.excludes_account__c.contains, DefiningType_CaseSafe=accountproductlinkcontroller, LastChild=true, DefiningType=AccountProductLinkController, EndLine=1310, MethodName_CaseSafe=contains, childIdx=1, BeginColumn=82, MethodName=contains}}: com.salesforce.rules.fls.apex.operations.SchemaBasedValidationAnalyzer.getDerivedApexValue(SchemaBasedValidationAnalyzer.java:89);com.salesforce.rules.fls.apex.operations.SchemaBasedValidationAnalyzer.getDerivedApexValue(SchemaBasedValidationAnalyzer.java:117);com.salesforce.rules.fls.apex.operations.SchemaBasedValidationAnalyzer.checkForValidation(SchemaBasedValidationAnalyzer.java:74);com.salesforce.rules.fls.apex.operations.FlsValidationCentral.checkSchemaBasedFlsValidation(FlsValidationCentral.java:69);com.salesforce.rules.fls.apex.AbstractFlsVisitor.afterVisit(AbstractFlsVisitor.java:80);com.salesforce.rules.fls.apex.ReadFlsRuleVisitor.afterVisit(ReadFlsRuleVisitor.java:61)
@rmohan20
Copy link
Contributor

rmohan20 commented Apr 3, 2023

@az-oolloow Thanks for reporting. Looks like you have a new code structure we haven't encountered in the past where you have a SOQL as an IF/ELSE condition.
Can you please paste for us a mocked-up version of what's in AccountProductLinkController.cls line 1307?

@rmohan20 rmohan20 added the BUG P3 Rarely Malfunction label Apr 3, 2023
@git2gus
Copy link

git2gus bot commented Apr 3, 2023

This issue has been linked to a new work item: W-12947502

@az-oolloow
Copy link
Author

@rmohan20 so this is somewhat complex but I tried to simplify it as best I could:

@AuraEnabled(cacheable=false)
public static List<SObject> getSomething(Id accountId) {
    if (!Schema.sObjectType.Account.isAccessible()
        || !Schema.sObjectType.Account.fields.Name.isAccessible()
        || !Schema.sObjectType.Account.fields.Id.isAccessible()
        || !Schema.sObjectType.Account.fields.Some_Custom_Field__c.isAccessible()
        || !Schema.sObjectType.Account.fields.Some_Custom_Field_2__c.isAccessible() // about ten more of these

        || !Schema.SObjectType.Custom_Object_One__c.isAccessible()
        || !Schema.SObjectType.Custom_Object_One__c.fields.Id.isAccessible()
        || !Schema.SObjectType.Custom_Object_One__c.fields.Name.isAccessible()
        || !Schema.SObjectType.Custom_Object_One__c.fields.Some_Other_Custom_Field__c.isAccessible()
        || !Schema.SObjectType.Custom_Object_One__c.fields.Some_Other_Custom_Field_2__c.isAccessible() // about 6 more of these
        
        || !Schema.SObjectType.Custom_Object_Two__c.isAccessible()
        || !Schema.SObjectType.Custom_Object_Two__c.fields.Id.isAccessible()
        || !Schema.SObjectType.Custom_Object_Two__c.fields.Name.isAccessible()
        || !Schema.SObjectType.Custom_Object_Two__c.fields.Valid_For_Sync__c.isAccessible() // this is a formula
        || !Schema.SObjectType.Custom_Object_Two__c.fields.Some_Other_Custom_Field__c.isAccessible()
        || !Schema.SObjectType.Custom_Object_Two__c.fields.Some_Other_Custom_Field_2__c.isAccessible() // about 6 more of these, note some field names do match across Custom_Object_One__c and Custom_Object_Two__c
        ) {
        throw new SecurityException('You do not have access to necessary data.');
    }
    Account account = [SELECT Id, Name, Some_Custom_Field__c, Some_Custom_Field_2__c, ... ///... and so on, all the ten from above
                       FROM Account WHERE Id = : accountId WITH USER_MODE];
    if (account.Some_Field__c == true) {
        return new List<SObject>();
    }
    List<SObject> result = new List<SObject>();
    // the next line is the one failing (reported as 1307)
    List<Custom_Object_Two__c> cots = [SELECT Id, Name, Some_Other_Custom_Field__c, Some_Other_Custom_Field_2__c, ... ///... and so on, all the six from above
                               FROM Custom_Object_Two__c
                               WHERE Valid_For_Sync__c = TRUE // this I think is one of the things that might break it
                                                         WITH USER_MODE
                                                         LIMIT 24999];
    for (Custom_Object_Two__c cot : cots)
    {
        if (cot.Some_Other_Custom_Field__c != null && cot.Some_Other_Custom_Field__c.contains(accountId)) {
            continue;
        }
        if (cot.Some_Other_Custom_Field_2__c) {
            result.add(cot);
            continue;
        }
        if (cot.Some_Other_Custom_Field_3__c != null && (cot.Some_Other_Custom_Field_3__c.contains(accountId) || (account.ParentId != null && cot.Some_Other_Custom_Field_3__c.contains(account.ParentId)))) {
            result.add(cot);
            continue;
        }
        // ... some more logic here...
    }
    // repeat the same flow for `Custom_Object_One__c` and add it to the `result` list
    return result;
}

The formula Valid_For_Sync__c is defined like so

AND(OR(ISBLANK(Start_Date__c),Start_Date__c&lt;=TODAY()),OR(ISBLANK(Start_Date__c),End_Date__c&gt;=TODAY()),Some_Field__c)

@rmohan20
Copy link
Contributor

rmohan20 commented May 1, 2023

@az-oolloow Thanks for the example. We'll check it out.

@stephen-carter-at-sf stephen-carter-at-sf added the SFGE Issues related to the Salesforce Graph Engine label May 23, 2024
@stephen-carter-at-sf stephen-carter-at-sf added the duplicate This issue or pull request already exists label Jun 3, 2024
@stephen-carter-at-sf
Copy link
Collaborator

Marking this as a duplicate of #1497

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG P3 Rarely Malfunction duplicate This issue or pull request already exists SFGE Issues related to the Salesforce Graph Engine
Projects
None yet
Development

No branches or pull requests

3 participants