{"record":{"id":"6592a6205da66dda","repo":"flowable/flowable-engine","slug":"no-multi-instance-behavior-found-for-execution","errorCode":null,"errorMessage":"No multi instance behavior found for ${execution}","messagePattern":"No multi instance behavior 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":65,"sourceCode":"        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());\n        }\n        \n        if (executionIsCompleted) {\n            VariableInstance nrOfCompletedInstancesVariable = miExecution.getVariableInstance(NUMBER_OF_COMPLETED_INSTANCES);","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/DeleteMultiInstanceExecutionCmd.java#L47-L83","documentation":"Thrown by DeleteMultiInstanceExecutionCmd.execute() when the activity element for the target execution has loop characteristics but its behavior is not a MultiInstanceActivityBehavior. The command only knows how to delete executions that belong to a genuine multi-instance activity. This guards against deleting executions of activities that merely resemble multi-instance constructs.","triggerScenarios":"Calling runtimeService.deleteMultiInstanceExecutionForExecution (or the underlying command) with an execution whose activity's behavior is not a MultiInstanceActivityBehavior, even though loopCharacteristics is non-null (that check passes at line 62).","commonSituations":"Custom or overridden activity behavior replaced the MI behavior; a parser/transformer bug left the behavior unassigned; calling the command on the inner (concurrent) child execution of an MI activity rather than a valid MI execution in a modified engine build.","solutions":["Verify the execution you pass actually belongs to a multi-instance user task or subprocess (check ACT_GE_BYTEARRAY/BPMN XML for loopCharacteristics on the activity).","Inspect the deployed BPMN model: the activity element must have an embedded MultiInstanceActivityBehavior; redeploy a correct process definition if behavior was customized.","Do not call this command on child/inner MI executions; use the multi-instance root execution id.","If behavior was overridden programmatically, ensure it extends MultiInstanceActivityBehavior."],"exampleFix":"// before\nruntimeService.deleteMultiInstanceExecutionForExecution(childExecutionId);\n// after\nExecution pi = runtimeService.createExecutionQuery().executionId(childExecutionId).singleResult();\nExecution miRoot = runtimeService.createProcessInstanceQuery()\n    .processInstanceId(pi.getProcessInstanceId()).singleResult(); // verify activity is MI first\nruntimeService.deleteMultiInstanceExecutionForExecution(miRootExecutionId);","handlingStrategy":"validation","validationCode":"boolean isMultiInstance(RuntimeService rs, String executionId) {\n    Execution e = rs.createExecutionQuery().executionId(executionId).singleResult();\n    return e != null && e.getActivityId() != null; // confirm via model inspection\n}","typeGuard":"if (execution == null || execution.getActivityId() == null) return false;","tryCatchPattern":null,"preventionTips":["Only invoke on executions whose activity has loopCharacteristics with an MI behavior","Use the MI root execution, not child executions","Inspect the deployed BPMN model before custom tooling manipulates MI structures"],"tags":["workflow","multi-instance","process-engine","invalid-state"],"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"}