{"record":{"id":"64bcf80fed2d55b3","repo":"flowable/flowable-engine","slug":"no-multi-instance-execution-found-for-execution","errorCode":null,"errorMessage":"No multi instance execution found for ${execution}","messagePattern":"No multi instance execution found for (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/DeleteMultiInstanceExecutionCmd.java","lineNumber":61,"sourceCode":"    protected String executionId;\n    protected boolean executionIsCompleted;\n\n    public DeleteMultiInstanceExecutionCmd(String executionId, boolean executionIsCompleted) {\n        this.executionId = executionId;\n        this.executionIsCompleted = executionIsCompleted;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager();\n        ExecutionEntity execution = executionEntityManager.findById(executionId);\n        \n        BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(execution.getProcessDefinitionId());\n        Activity miActivityElement = (Activity) bpmnModel.getFlowElement(execution.getActivityId());\n        MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = miActivityElement.getLoopCharacteristics();\n        \n        if (miActivityElement.getLoopCharacteristics() == null) {\n            throw new FlowableException(\"No multi instance execution found for \" + execution);\n        }\n        \n        if (!(miActivityElement.getBehavior() instanceof MultiInstanceActivityBehavior)) {\n            throw new FlowableException(\"No multi instance behavior found for \" + execution);\n        }\n        \n        if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, execution.getProcessDefinitionId())) {\n            throw new FlowableException(\"Flowable 5 process definitions are not supported for \" + execution);\n        }\n        \n        ExecutionEntity miExecution = getMultiInstanceRootExecution(execution);\n        executionEntityManager.deleteChildExecutions(execution, \"Delete MI execution\", false);\n        executionEntityManager.deleteExecutionAndRelatedData(execution, \"Delete MI execution\", false);\n        \n        int loopCounter = 0;\n        if (multiInstanceLoopCharacteristics.isSequential()) {\n            SequentialMultiInstanceBehavior miBehavior = (SequentialMultiInstanceBehavior) miActivityElement.getBehavior();\n            loopCounter = miBehavior.getLoopVariable(execution, miBehavior.getCollectionElementIndexVariable());","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/DeleteMultiInstanceExecutionCmd.java#L43-L79","documentation":"DeleteMultiInstanceExecutionCmd deletes an execution of a multi-instance activity. It reads the current activity's loop characteristics from the BPMN model; if the activity has no MultiInstanceLoopCharacteristics (or the model lookup yields a non-Activity element), it throws FlowableException because there is no multi-instance execution to delete.","triggerScenarios":"RuntimeService.deleteMultiInstanceExecutionForProcessInstance/deleteMultiInstanceExecution... on an execution whose current activity is not a multi-instance (MI) activity, or whose activityId does not resolve to an Activity with loopCharacteristics in the deployed BPMN.","commonSituations":"Calling the delete-multi-instance API after the MI activity already completed; a wrong execution id pointing at a child/regular execution; changing the process model so the activity is no longer multi-instance while old instances are still running (model/version drift).","solutions":["Verify the execution's current activity is a multi-instance activity before calling (check bpmnModel flow element's getLoopCharacteristics() != null).","Pass the execution id of the multi-instance root/child execution, not an unrelated execution.","Ensure the running instance uses the same process definition version where the activity is still multi-instance.","Catch FlowableException and skip when the activity is not multi-instance if your logic only conditionally needs deletion."],"exampleFix":"// before\nruntimeService.deleteMultiInstanceExecutionForProcessInstance(executionId);\n// after\nExecutionEntity exec = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult();\nBpmnModel bpmnModel = repositoryService.getBpmnModel(exec.getProcessDefinitionId());\nFlowElement el = bpmnModel.getFlowElement(exec.getActivityId());\nif (el instanceof Activity && ((Activity) el).getLoopCharacteristics() != null) {\n    runtimeService.deleteMultiInstanceExecutionForProcessInstance(executionId);\n}","handlingStrategy":"validation","validationCode":"ExecutionEntity exec = (ExecutionEntity) runtimeService.createExecutionQuery()\n        .executionId(executionId).singleResult();\nBpmnModel bpmnModel = repositoryService.getBpmnModel(exec.getProcessDefinitionId());\nFlowElement el = bpmnModel.getFlowElement(exec.getActivityId());\nboolean isMultiInstance = el instanceof Activity && ((Activity) el).getLoopCharacteristics() != null;\nif (isMultiInstance) {\n    runtimeService.deleteMultiInstanceExecutionForProcessInstance(executionId);\n}","typeGuard":"boolean isMultiInstanceExecution(RepositoryService rs, ExecutionEntity exec) {\n    FlowElement el = rs.getBpmnModel(exec.getProcessDefinitionId()).getFlowElement(exec.getActivityId());\n    return el instanceof Activity && ((Activity) el).getLoopCharacteristics() != null;\n}","tryCatchPattern":"try {\n    runtimeService.deleteMultiInstanceExecutionForProcessInstance(executionId);\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"No multi instance execution found\")) {\n        log.info(\"Execution {} is not multi-instance; skipping\", executionId);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Only call multi-instance execution APIs on executions currently sitting in an MI activity.","Re-check the deployed BPMN after model changes; old instances may run a definition where the activity differs.","Use the MI root/child execution id from the execution tree, not an arbitrary execution."],"tags":["flowable","multi-instance","bpmn","state-mismatch"],"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"}