Skip to content

Nebula Logger inside Invocable Action invoked from Agentforce Grid fails with System.UnexpectedException: Script-thrown exception #964

@JeroenSfdc

Description

@JeroenSfdc

Package Edition of Nebula Logger

Managed Package

Package Version of Nebula Logger

v4.17.0

Bug Summary

We're experimenting with Agentforce Grid. Having Nebula Logger sprinkled inside Invocable code makes the Invocable action fail. Even the most simplistic Invocable code is enough to trigger the failure.

Note: This might be an issue with Agentforce Grid itself, and I have raised this with the Agentforce Grid product team as well.

Code Snippet

Here is the minimal Invocable code required to reproduce the issue:

public with sharing class TpiSearchAutomatedTestInvocable {

    public class Request {
        @InvocableVariable(Label='VIN')
        public String vin;
    }

    public class Result {
        @InvocableVariable(Label='Success or failure.')
        public Boolean success;
    }

    @InvocableMethod(Label='Dummy invocable')
    public static List<Result> execute(List<Request> requests) {
        Nebula.Logger.debug('test'); // This throws UnexpectedException
        Nebula.Logger.saveLog();

        Result result = new Result();
        List<Result> results = new List<Result>();

        for (Request req : requests) {
            results.add(result);
        }

        return results;
    }
}

Log Output
The debug logs show a MISSING_SCENARIO_ERROR_MESSAGE variable assignment right before the System.UnexpectedException is thrown:

20:11:26.1 (20691180)|VARIABLE_ASSIGNMENT|[43]|Nebula.Logger.MISSING_SCENARIO_ERROR_MESSAGE|"No logger scenario s (57 more) ..."
20:11:26.1 (20708731)|METHOD_ENTRY|[15]|01p9O00000FtZOZ|Nebula.Logger.Logger()
20:11:26.1 (20714224)|STATEMENT_EXECUTE|[15]
20:11:26.1 (20720794)|ENTERING_MANAGED_PKG|Nebula
20:11:26.1 (21646011)|ENTERING_MANAGED_PKG|Nebula
20:11:26.1 (21667092)|ENTERING_MANAGED_PKG|Nebula
20:11:26.1 (25968073)|METHOD_EXIT|[15]|Nebula.Logger
20:11:26.1 (26007479)|SYSTEM_MODE_EXIT|false
20:11:26.1 (26502475)|FATAL_ERROR|System.UnexpectedException: Script-thrown exception

(System Code)
Class.TpiSearchAutomatedTestInvocable.execute: line 43, column 1
20:11:26.1 (26512608)|FATAL_ERROR|System.UnexpectedException: Script-thrown exception

Attempted Workaround
Because of the Nebula.Logger.MISSING_SCENARIO_ERROR_MESSAGE logged prior to the crash, I attempted to explicitly set the scenario before logging:

```Nebula.Logger.setScenario('DEFAULT_LOGGER_SCENARIO');
// Nebula.Logger.debug('test');
// Nebula.Logger.saveLog();

However, the execution fails immediately on the Nebula.Logger.setScenario() statement as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions