{"record":{"id":"6cfe56c429bd1579","repo":"flowable/flowable-engine","slug":"error-while-completing-sub-process-of-execution-6cfe56","errorCode":null,"errorMessage":"Error while completing sub process of execution + scopeExecutionEntity","messagePattern":"Error while completing sub process of execution \\+ scopeExecutionEntity","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/TerminateEndEventActivityBehavior.java","lineNumber":140,"sourceCode":"\r\n        } else if (scopeExecutionEntity.getParentId() == null\r\n                && scopeExecutionEntity.getSuperExecutionId() != null) { // CallActivity\r\n\r\n            ExecutionEntity callActivityExecution = scopeExecutionEntity.getSuperExecution();\r\n            CallActivity callActivity = (CallActivity) callActivityExecution.getCurrentFlowElement();\r\n            \r\n            SubProcessActivityBehavior subProcessActivityBehavior = null;\r\n\r\n            // copy variables before destroying the ended sub process instance (call activity)\r\n            subProcessActivityBehavior = (SubProcessActivityBehavior) callActivity.getBehavior();\r\n            try {\r\n                subProcessActivityBehavior.completing(callActivityExecution, scopeExecutionEntity);\r\n            } catch (RuntimeException e) {\r\n                LOGGER.error(\"Error while completing sub process of execution {}\", scopeExecutionEntity, e);\r\n                throw e;\r\n            } catch (Exception e) {\r\n                LOGGER.error(\"Error while completing sub process of execution {}\", scopeExecutionEntity, e);\r\n                throw new FlowableException(\"Error while completing sub process of execution \" + scopeExecutionEntity, e);\r\n            }\r\n\r\n            if (callActivity.hasMultiInstanceLoopCharacteristics()) {\r\n\r\n                sendProcessInstanceCompletedEvent(scopeExecutionEntity, execution.getCurrentFlowElement());\r\n                MultiInstanceActivityBehavior multiInstanceBehavior = (MultiInstanceActivityBehavior) callActivity.getBehavior();\r\n                multiInstanceBehavior.leave(callActivityExecution);\r\n                executionEntityManager.deleteProcessInstanceExecutionEntity(scopeExecutionEntity.getId(), \r\n                                execution.getCurrentFlowElement().getId(), \"terminate end event\", false, false, false);\r\n\r\n            } else {\r\n                sendProcessInstanceCompletedEvent(scopeExecutionEntity, execution.getCurrentFlowElement());\r\n                executionEntityManager.deleteProcessInstanceExecutionEntity(scopeExecutionEntity.getId(), \r\n                                execution.getCurrentFlowElement().getId(), \"terminate end event\", false, false, false);\r\n                ExecutionEntity superExecutionEntity = executionEntityManager.findById(scopeExecutionEntity.getSuperExecutionId());\r\n                CommandContextUtil.getAgenda(commandContext).planTakeOutgoingSequenceFlowsOperation(superExecutionEntity, true);\r\n\r\n            }\r","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/TerminateEndEventActivityBehavior.java#L122-L158","documentation":"When a terminate end event finishes an embedded subprocess scope, Flowable calls SubProcessActivityBehavior.completing. If that call throws a checked Exception it is logged and rethrown wrapped as this FlowableException with the failing scope execution in the message. It indicates the scope-completion callback for the subprocess failed.","triggerScenarios":"defaultTerminateEndEventBehaviour handling a terminate end event inside a subprocess/callActivity with multi-instance characteristics; the completing() call on the subprocess behavior throws an exception (e.g. persistence, variable handling failure).","commonSituations":"Terminate end event inside an embedded subprocess whose scope teardown fails due to concurrent modification or data-store errors; multi-instance subprocess termination interacting with broken execution tree state after failed upgrades or manual DB edits.","solutions":["Look at the LOGGER output directly above this throw for the root cause stack trace","Check execution-tree consistency in ACT_RU_EXECUTION for the process instance (orphans/duplicates) after any manual DB intervention","Reproduce with a minimal process (terminate end event in subprocess) and inspect the cause","Upgrade to the latest Flowable patch release, as execution-tree teardown bugs have been fixed historically","Avoid terminating inside multi-instance subprocesses until the underlying cause is fixed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.trigger(executionId);\n} catch (FlowableException e) {\n    logger.error(\"Terminate/scope completion failed for execution \" + executionId, e);\n    // inspect root cause before retrying or restoring state\n}","preventionTips":["Never edit ACT_RU_* tables manually","Keep the engine on the latest patch release","Test terminate end events inside subprocesses/multi-instance before production","Avoid terminate end events inside multi-instance subprocesses unless required"],"tags":["terminate-end-event","subprocess","scope-completion","bpmn"],"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-14T11:17:12.474Z"}