AEMaaCS GOTO workflow step, not routing to next step. javax.jcr.PathNotFoundException.
Hi wonderful people,
I have a custom post-processing workflow model which gets triggered by CustomDamWorkflowRunnerImpl.
This gets triggered after AEM completes all of its internal asset compute processing.
The first step in the workflow model is a GOTO process which calls a sling service to determine the return value.
GOTO process ECMA script below -
function check() {
var returnVal = false;
var service = sling.getService(Packages.com.adobe.service.TrialServiceInterface);
if (service && service.isEnabled()) {
returnVal = true
}
log.info("Return value: " + returnVal);
return returnVal;
}
Workflow model: Based off the script result, GOTO step should either redirect to the TARGET_NODE_PATH step or carry on with its normal route to the next step.

Issue:
I see the ECMA script executing successfully.
It then it leads to a PathNotFoundException (possibly during its internal routing mechanism), but the path exists in var. I have a hunch this is permission related, any insights on how to tackle this issue is highly appreciated.
05.05.2022 23:45:58.349 [cm-p16597-e60753-aem-author-5dcc8c5cb8-7l9bn] *INFO* [JobHandler: /var/workflow/instances/server1227/2022-05-05/asset-post-processing_1:/content/dam/trial-dam/camino.jpg] libs.workflow.scripts.dynamic$ecma Return value: false
05.05.2022 23:45:58.352 [cm-p16597-e60753-aem-author-5dcc8c5cb8-7l9bn] *ERROR* [JobHandler: /var/workflow/instances/server1227/2022-05-05/asset-post-processing_1:/content/dam/trial-dam/camino.jpg] com.adobe.granite.workflow.core.job.JobHandler Error executing workflow step
com.adobe.granite.workflow.WorkflowException: Process execution resulted in an error
at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:204) [com.adobe.granite.workflow.core:2.1.78]
Caused by: com.adobe.granite.workflow.WorkflowException: Unable to retrieve workflow instance: /var/workflow/instances/server1227/2022-05-05/asset-post-processing_1
at com.adobe.granite.workflow.core.jcr.WorkflowManager.getWorkflowInstance(WorkflowManager.java:191) [com.adobe.granite.workflow.core:2.1.78]
... 8 common frames omitted
Caused by: javax.jcr.PathNotFoundException: /var/workflow/instances/server1227/2022-05-05/asset-post-processing_1
at org.apache.jackrabbit.oak.jcr.session.SessionImpl.getItem(SessionImpl.java:401) [org.apache.jackrabbit.oak-jcr:1.42.0.T20220401090340-a7d9bc5]
at com.adobe.granite.repository.impl.CRX3SessionImpl.getItem(CRX3SessionImpl.java:180) [com.adobe.granite.repository:1.8.28]
at com.adobe.granite.workflow.core.jcr.WorkflowManager.getWorkflowNode(WorkflowManager.java:1045) [com.adobe.granite.workflow.core:2.1.78]
at com.adobe.granite.workflow.core.jcr.WorkflowManager.getWorkflowInstance(WorkflowManager.java:185) [com.adobe.granite.workflow.core:2.1.78]
... 13 common frames omitted
Thanks in advance.