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] Internal Execution Error - Apex #1670

Closed
micharozen opened this issue Nov 12, 2024 · 2 comments
Closed

[BUG] Internal Execution Error - Apex #1670

micharozen opened this issue Nov 12, 2024 · 2 comments
Labels
SFGE Issues related to the Salesforce Graph Engine

Comments

@micharozen
Copy link

Have you tried to resolve this issue yourself first?

Yes

Bug Description

Error Message:

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: NullPointerException: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "com.salesforce.rules.fls.apex.operations.ObjectFieldInfo.getObjectName()" is null: com.salesforce.graph.ops.ObjectFieldUtil.regroupByObject(ObjectFieldUtil.java:26);com.salesforce.rules.fls.apex.operations.FlsViolationMessageUtil.consolidateFlsViolations(FlsViolationMessageUtil.java:54);com.salesforce.rules.PathBasedRuleRunner.convertFlsInfoToViolations(PathBasedRuleRunner.java:215);com.salesforce.rules.PathBasedRuleRunner.executeRulesOnPaths(PathBasedRuleRunner.java:189);com.salesforce.rules.PathBasedRuleRunner.runRules(PathBasedRuleRunner.java:88);com.salesforce.rules.ThreadableRuleExecutor$CallableExecutor.runRules(ThreadableRuleExecutor.java:228)

Code:

`global void execute(Database.BatchableContext BC, List<Invoice__c> scope) {
// Vérifier les permissions FLS pour Task
if(!PermissionUtils.checkFieldAccessibility('Task', new String[]{
'Subject', 'Description', 'Status', 'ActivityDate', 'WhatId', 'Type', 'OwnerId'
})) {
throw new SecurityException('Insufficient permissions to access Task fields');
}

    List<Task> tasks = new List<Task>();
    List<Invoice__c> invoicesToUpdate = new List<Invoice__c>();
    
    Integer remainingCounter = 0;
    
    for (Invoice__c invoice : scope) {
        remainingCounter = Integer.valueOf(invoice.NumberOfInstallmentPayment__c - invoice.NumberRemainingPayments__c) + 1;
        tasks.add(TaskManager.createTask(
            'Rappel Relance Paiement N°' + remainingCounter, 
            (System.Label.INVOICE_PAYMENT_REMINDER).replaceAll('XXX', String.valueOf(remainingCounter)), 'Not Started', 
            null, 
            invoice.LastPaymentReminderDate__c == null ? invoice.InvoiceSentDate__c.addMonths(1) : invoice.LastPaymentReminderDate__c.addMonths(1), 
            invoice.Id, 
            'Relance Paiement', 
            invoice.CreatedById));
        invoice.LastPaymentReminderDate__c = invoice.LastPaymentReminderDate__c.addMonths(1);
    }

    // Vérifier les permissions de mise à jour pour Invoice
    if(!PermissionUtils.checkFieldAccessibility('Invoice__c', new String[]{'LastPaymentReminderDate__c'})){
        throw new SecurityException('Insufficient permissions to update Invoice fields');
    }

    if(PermissionUtils.hasCRUDPermissions(tasks, Constants.CREATABLE_OP)){
        Database.insert(tasks, false);
    }

    if(PermissionUtils.hasCRUDPermissions(scope, Constants.UPDATABLE_OP)){
        Database.update(scope, false);
    }
}`

Output / Logs

No response

Steps To Reproduce

1.Have this bloc in sf project
2. run : sf scanner run dfa --format csv --outfile CodeAnalyzerDFA.csv --target ./ --projectdir ./ --category Security

Expected Behavior

I expect no flag detected in this bloc

Operating System

MacOS SOnoma 14.6.1

Salesforce CLI Version

@salesforce/cli/2.48.6 darwin-arm64 node-v20.15.0

Code Analyzer Plugin (@salesforce/sfdx-scanner) Version

@salesforce/sfdx-scanner 4.3.0

Java Version

java version "17.0.5" 2022-10-18 LTS

Additional Context (Screenshots, Files, etc)

No response

Workaround

No response

Urgency

Moderate

@jfeingold35
Copy link
Collaborator

@micharozen , the error message is talking about a string.toLowerCase() call and an ObjectFieldInfo.getObjectName() call, and those aren't visible in the code you posted. Without seeing those, this looks like what's happening is that string.toLwoercase() is being called on a null value. Is it possible for you to identify that line?

@stephen-carter-at-sf stephen-carter-at-sf added the SFGE Issues related to the Salesforce Graph Engine label Nov 13, 2024
@stephen-carter-at-sf
Copy link
Collaborator

Duplicate of #1497

@stephen-carter-at-sf stephen-carter-at-sf marked this as a duplicate of #1497 Nov 13, 2024
@stephen-carter-at-sf stephen-carter-at-sf closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 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