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

InternalExecutionError Graph Engine identified your source and sink, but you must manually verify that you have a sanitizer in this path. #1386

Closed
Kaushal1829 opened this issue Mar 11, 2024 · 8 comments
Labels
BUG P2 Malfunctioning Often duplicate This issue or pull request already exists SFGE Issues related to the Salesforce Graph Engine

Comments

@Kaushal1829
Copy link

Kaushal1829 commented Mar 11, 2024

CodeAnalyzerDFA-Feb15a.csv

I have been facing this issue did not get any resolution please help someone:

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: UnexpectedException: ArrayLoadExpression{properties={FirstChild=true, BeginLine=704, DefiningType_CaseSafe=visualizationscontroller, LastChild=true, DefiningType=VisualizationsController, EndLine=704, childIdx=0, BeginColumn=55}}: com.salesforce.graph.symbols.PathScopeVisitor.afterVisit(PathScopeVisitor.java:761);com.salesforce.graph.symbols.DefaultSymbolProviderVertexVisitor.afterVisit(DefaultSymbolProviderVertexVisitor.java:737);com.salesforce.graph.vertex.ArrayLoadExpressionVertex.afterVisit(ArrayLoadExpressionVertex.java:58);com.salesforce.graph.ops.expander.ApexPathExpander.performAfterVisit(ApexPathExpander.java:577);com.salesforce.graph.ops.expander.ApexPathExpander.visit(ApexPathExpander.java:536);com.salesforce.graph.ops.expander.ApexPathExpander.visit(ApexPathExpander.java:523)

For reference, I am sharing one class and method where I am facing an internal execution error :

Facing the issue on below methods:

Especially can check in this method, private Date getStartDate() mentioned in error line 704 can see the below query

else if(String.valueOf(objectId.getSObjectType()) == LEADVAR){
returnStartDate = ((DateTime) [SELECT MIN(Response_Completed_Date__c) FROM Survey_Response__c WHERE Lead_Id__c = :objectId and Survey_Id__c = :surveyId][0].get('expr0')).date();

setAverageCountVisible
getStartMonth
getStartDay
getStartYear
validateFilter
identifyAvailableTrends
getSurveyConfig
applyFilters
getColorSet
prepareChartsJSON
getTimeTrendOptions
QuarterData
getSurveyList

public void applyFilters(){
if(this.validateFilter()){ //Validate input parameters before proceeding
if(surveyId.equalsIgnoreCase(SURVEY_NONE)){
hasError = true;
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,Label.No +SPACE_STRING+ Label.data_available));
}
else {
//Set Response SOQL start and end filters
sd = DateTime.newInstanceGMT(selectedStartDate, Time.newInstance(0,0,0,0)).addSeconds(-timeOffset/1000);
ed = DateTime.newInstanceGMT(selectedEndDate.addDays(1), Time.newInstance(0,0,0,0)).addSeconds(-timeOffset/1000);
numberOfResponses = 0;
try{
survey = Selectors.getKMSurveyDetailsById(new Set{surveyId}, String.valueOf(objectId.getSObjectType()).toLowerCase()).get(surveyId);

                //Initialize KeyMetric model map to deafult values
                this.initializeKMModelMap();

                //Chart Calculations
                gaugeAndNoneTrendCalculations();
                timeTrendCalculations();

                //Call methods that forms chart's Data
                this.prepareChartsJSON();

                this.keyMetricModelList = getKeyMeticModelList();
                setAverageCountVisible();
            }
            catch(CustomException.FLSException ex){
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,Label.FLS_CRUD_Error_Message));
                hasError = true;
            }
        }
    }
}
        for(Integer km : filteredKMModels){
            final KeyMetricModel keyMetricModelObj = keyMetricModelMap.get(km);
            String xValue = 'Q#QUARTER#-#YEAR#'
                .replace('#QUARTER#', String.valueOf(row.get(LABEL_QUARTER)))
                .replace('#YEAR#', String.valueOf(row.get(LABEL_YEAR)));
            String fieldLabel = AGGREGATE_TO_LABEL.get(AGG_AVG) + km;
            keyMetricModelObj.timeTrendMap.put(xValue, (Decimal) row.get(fieldLabel));
            keyMetricModelObj.timeTrendColorMap.put(xValue, getColorSet(km, (Decimal) row.get(fieldLabel)));
        }
    }
}

public void prepareChartsJSON()
{
    chartsMap = new Map<Integer, ChartModel>();
    try {
        
        //Check NoData And OutOfRange scenarios
        for (Integer i = 0; i < keyMetricModelMap.values().size(); i++) {
            KeyMetricModel kmModel = keyMetricModelMap.values()[i];

            this.setNoDataAndOutOfRange(kmModel.KeyMetricType);
            
            if(!kmModel.hasError && kmModel.order != NULL){
                chartsMap.put(kmModel.KeyMetricType, getChartModel(kmModel.KeyMetricType, kmModel.chartType));
            }
        }
        chartsJSON = JSON.serialize(chartsMap);
    }
    catch(Exception e){
        throw e;

public void QuarterData(){
Set filteredKMModels = filterKMModels(CHART_TYPE_BAR);

    //return if no valid charts found.
    if(filteredKMModels.isEmpty())
        return;

    //Getting Filtered Fields to Query
    Set<String> fieldsToQuery = getFieldsToQuery(filteredKMModels, new Set<String>{AGG_AVG, AGG_COUNT});

    //Query generation
    String query = populateQuery(QUERY_BAR_QUARTERLY, fieldsToQuery);

    //Generating structure for valid charts to store data
    Date tempDate = selectedStartDate.toStartOfMonth();
    while (selectedEndDate >= tempDate) {
        for(Integer km : filteredKMModels){
            final KeyMetricModel keyMetricModelObj = keyMetricModelMap.get(km);
            String xValue = 'Q#QUARTER#-#YEAR#'
                .replace('#QUARTER#', String.valueOf(MONTH_TO_QUARTER.get(tempDate.month())))
                .replace('#YEAR#', String.valueOf(tempDate.year()));
            keyMetricModelObj.timeTrendMap.put(xValue, null);
            keyMetricModelObj.timeTrendColorMap.put(xValue, '#ffffff');
        }
        tempDate = tempDate.addMonths(3);
    }

    //Fill Data
    this.numberOfResponses = 0;
    for(AggregateResult row : Database.query(query)){
        this.numberOfResponses += integer.valueOf(row.get(LABEL_COUNT_NAME));
        for(Integer km : filteredKMModels){
            final KeyMetricModel keyMetricModelObj = keyMetricModelMap.get(km);
            String xValue = 'Q#QUARTER#-#YEAR#'
                .replace('#QUARTER#', String.valueOf(row.get(LABEL_QUARTER)))
                .replace('#YEAR#', String.valueOf(row.get(LABEL_YEAR)));
            String fieldLabel = AGGREGATE_TO_LABEL.get(AGG_AVG) + km;
            keyMetricModelObj.timeTrendMap.put(xValue, (Decimal) row.get(fieldLabel));
            keyMetricModelObj.timeTrendColorMap.put(xValue, getColorSet(km, (Decimal) row.get(fieldLabel)));
        }
    }
}

private Date getStartDate()
{
Date returnStartDate = fetchStartDate();
if(returnStartDate == NULL_DATE)
{
try{
if(!SURVEY_NONE.equalsIgnoreCase(surveyId)){
if(String.valueOf(objectId.getSObjectType()) == ACCOUNTVAR){
returnStartDate = ((DateTime) [SELECT MIN(Response_Completed_Date__c) FROM Survey_Response__c WHERE Account__c = :objectId and Survey_Id__c = :surveyId][0].get('expr0')).date();
}
else if(String.valueOf(objectId.getSObjectType()) == CONTACTVAR){
returnStartDate = ((DateTime) [SELECT MIN(Response_Completed_Date__c) FROM Survey_Response__c WHERE Contact_Id__c = :objectId and Survey_Id__c = :surveyId][0].get('expr0')).date();
}
else if(String.valueOf(objectId.getSObjectType()) == LEADVAR){
returnStartDate = ((DateTime) [SELECT MIN(Response_Completed_Date__c) FROM Survey_Response__c WHERE Lead_Id__c = :objectId and Survey_Id__c = :surveyId][0].get('expr0')).date();
}
}
}
catch(NullPointerException ex){
//this exceptions occurs if no response is present for that survey
//handled in ui - survey with no responses are not visible in picklist
}
}
returnStartDate = returnStartDate == NULL_DATE ? Date.newInstance(2015,1,1) : returnStartDate;
return returnStartDate;

}

Steps To Reproduce:
I ran the following scanner:
sf scanner run dfa --format=csv --outfile=CodeAnalyzerDFA-Feb15a.csv --target="./" --projectdir="./" --category="Security"

Desktop:
Provide these details:

Operating System: Windows11
Code Analyzer version: v3.20.0
Salesforce CLI version: @salesforce/cli/2.30.8 win32-x64 node-v20.11.1
Additional Context:

Workaround:
Tried to run the dfA scanner commend and got the issue like Unexpected exception only did not find the exact solution i have methods and class where got the issue.
After running the code analyzer getting issues in 3 and 4 classes internal execution error
Urgency: High

@johnbelosf
Copy link
Collaborator

hi @Kaushal1829 - thanks for this. You need to use the "Report a Bug with scanner run dfa" to report issues related with Graph Engine. Can you please update this accordingly? Thank you.

@Kaushal1829
Copy link
Author

@johnbelosf I use the same "Report a Bug with scanner run dfa" to report issue related with Graph Engine

@johnbelosf
Copy link
Collaborator

@Kaushal1829 you need to follow the troubleshooting steps and then use the template provided

@Kaushal1829
Copy link
Author

Kaushal1829 commented Mar 11, 2024

@johnbelosf I have updated the scenario and troubleshooting steps did I miss something please let me know ill update

@jag-j jag-j added the BUG P2 Malfunctioning Often label Mar 13, 2024
Copy link

git2gus bot commented Mar 13, 2024

Error while creating work item!

@jag-j jag-j removed the BUG P2 Malfunctioning Often label Mar 13, 2024
@jfeingold35 jfeingold35 added the BUG P2 Malfunctioning Often label Mar 13, 2024
@stephen-carter-at-sf stephen-carter-at-sf removed the BUG P2 Malfunctioning Often label Mar 13, 2024
Copy link

git2gus bot commented Mar 13, 2024

Error while creating work item!

@jag-j jag-j changed the title InternalExecutionError 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: UnexpectedException: InternalExecutionError Graph Engine identified your source and sink, but you must manually verify that you have a sanitizer in this path. Mar 13, 2024
@jag-j jag-j added the BUG P2 Malfunctioning Often label Mar 13, 2024
Copy link

git2gus bot commented Mar 13, 2024

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

@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 P2 Malfunctioning Often 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

5 participants