{"record":{"id":"7a794ca779656e4c","repo":"flowable/flowable-engine","slug":"execution-is-not-of-type-process-instance","errorCode":null,"errorMessage":"${execution} is not of type process instance","messagePattern":"(.+?) is not of type process instance","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/EvaluateConditionalEventsCmd.java","lineNumber":47,"sourceCode":"\n    protected Map<String, Object> processVariables;\n    protected Map<String, Object> transientVariables;\n    protected boolean async;\n\n    public EvaluateConditionalEventsCmd(String processInstanceId, Map<String, Object> processVariables) {\n        super(processInstanceId);\n        this.processVariables = processVariables;\n    }\n\n    public EvaluateConditionalEventsCmd(String processInstanceId, Map<String, Object> processVariables, Map<String, Object> transientVariables) {\n        this(processInstanceId, processVariables);\n        this.transientVariables = transientVariables;\n    }\n\n    @Override\n    protected Object execute(CommandContext commandContext, ExecutionEntity execution) {\n        if (!execution.isProcessInstanceType()) {\n            throw new FlowableException(execution + \" is not of type process instance\");\n        }\n        \n        if (processVariables != null) {\n            execution.setVariables(processVariables);\n        }\n\n        if (transientVariables != null) {\n            execution.setTransientVariables(transientVariables);\n        }\n\n        CommandContextUtil.getAgenda(commandContext).planEvaluateConditionalEventsOperation(execution);\n\n        return null;\n    }\n\n    @Override\n    protected String getSuspendedExceptionMessagePrefix() {\n        return \"Cannot evaluate conditions for\";","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/EvaluateConditionalEventsCmd.java#L29-L65","documentation":"EvaluateConditionalEventsCmd requires the execution it operates on to be the top-level process instance. If the execution passed to the command is a child/concurrent execution, execute() throws this FlowableException because conditional boundary/intermediate events are only evaluated at process-instance scope.","triggerScenarios":"Passing a child execution (e.g. a concurrent or scope execution) to the command that evaluates conditional events, instead of the process instance execution.","commonSituations":"Custom Java delegates or listeners that fetch an execution via ExecutionEntityManager and invoke conditional-event evaluation on the wrong execution; custom command interceptors operating on child executions after parallel gateway forks.","solutions":["Pass the process instance execution: resolve it via execution.getProcessInstanceId() + ExecutionEntityManager.findById(), or use execution.getRootProcessInstanceId()/getProcessInstance()","Verify with execution.isProcessInstanceType() before invoking the command","Refactor custom code to use the RuntimeService APIs (e.g. runtimeService.createExecutionQuery().processInstanceId(...).singleResult()) rather than raw commands on arbitrary executions"],"exampleFix":"// before\ncommandExecutor.execute(new EvaluateConditionalEventsCmd(processInstanceId, vars), childExecution);\n// after\nExecutionEntity procInst = (ExecutionEntity) runtimeService.createExecutionQuery()\n    .executionId(childExecution.getProcessInstanceId()).singleResult();\ncommandExecutor.execute(new EvaluateConditionalEventsCmd(processInstanceId, vars), procInst);","handlingStrategy":"validation","validationCode":"ExecutionEntity pi = execution.isProcessInstanceType() ? execution : (ExecutionEntity) runtimeService.createExecutionQuery().executionId(execution.getProcessInstanceId()).singleResult();\nif (pi == null || !pi.isProcessInstanceType()) throw new IllegalStateException(\"need process instance execution\");","typeGuard":"boolean isProcessInstance(Execution e) { return e instanceof ExecutionEntity ee && ee.isProcessInstanceType(); }","tryCatchPattern":"try { cmd.execute(commandContext); } catch (FlowableException e) { if (e.getMessage().contains(\"is not of type process instance\")) { /* re-resolve root process instance and retry */ } else throw e; }","preventionTips":["Always resolve the root/process-instance execution before process-instance-scoped commands","Use isProcessInstanceType() as a cheap precondition check","Prefer RuntimeService facade APIs over raw commands"],"tags":["flowable","execution-scope","process-instance"],"backgroundTag":"invalid-state-transition","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}