{"record":{"id":"07cac96d36f54243","repo":"flowable/flowable-engine","slug":"cannot-automap-activity-migration-for-executi","errorCode":null,"errorMessage":"Cannot autoMap activity migration for '\" + executionActivityId + \"'. Cannot migrate arbitrarily inside a Multi Instance container '\" + newFlowElementMIParentId","messagePattern":"Cannot autoMap activity migration for '\" \\+ executionActivityId \\+ \"'\\. Cannot migrate arbitrarily inside a Multi Instance container '\" \\+ newFlowElementMIParentId","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/migration/ProcessInstanceMigrationManagerImpl.java","lineNumber":741,"sourceCode":"                    FlowElement newModelFlowElement = newModel.getFlowElement(executionActivityId);\n                    String newFlowElementMIParentId = getFlowElementMultiInstanceParentId(newModelFlowElement);\n\n                    if (newFlowElementMIParentId != null) {\n                    \tboolean noChangesInMI = false;\n                    \tActivity currentMIElement = (Activity) currentModel.getFlowElement(newFlowElementMIParentId);\n                    \tActivity newMIElement = (Activity) newModel.getFlowElement(newFlowElementMIParentId);\n                    \tif (currentMIElement.getClass().getName().equals(newMIElement.getClass().getName()) &&\n                    \t\t\thasSameLoopCharacteristics(currentMIElement, newMIElement)) {\n                    \t\t\n                    \t\tif (!(currentMIElement instanceof SubProcess)) {\n                    \t\t\tnoChangesInMI = true;\n                    \t\t} else if (hasSameSubProcessContent((SubProcess) currentMIElement, (SubProcess) newMIElement)) {\n                    \t\t\tnoChangesInMI = true;\n                    \t\t}\n                    \t}\n                    \t\n                    \tif (!noChangesInMI) {\n                    \t\tthrow new FlowableException(\"Cannot autoMap activity migration for '\" + executionActivityId + \"'. Cannot migrate arbitrarily inside a Multi Instance container '\" + newFlowElementMIParentId);\n                    \t}\n                    }\n\n                    LOGGER.debug(\"Auto mapping activity '{}'\", executionActivityId);\n                    List<ExecutionEntity> executionEntities = filteredExecutionsByActivityId.get(executionActivityId);\n                    if (executionEntities.size() > 1) {\n                        List<String> executionIds = executionEntities.stream().map(ExecutionEntity::getId).collect(Collectors.toList());\n                        mainProcessChangeActivityStateBuilder.moveExecutionsToSingleActivityId(executionIds, executionActivityId);\n                    } else {\n                        mainProcessChangeActivityStateBuilder.moveExecutionToActivityId(executionEntities.get(0).getId(), executionActivityId);\n                    }\n                    \n                } else {\n                    if (!(currentModelFlowElement instanceof CallActivity)) {\n                        throw new FlowableException(\"Migration Activity mapping missing for activity definition Id:'\" + \n                        \t\texecutionActivityId + \"' or its MI Parent\");\n                    }\n                }","sourceCodeStart":723,"sourceCodeEnd":759,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/migration/ProcessInstanceMigrationManagerImpl.java#L723-L759","documentation":"Thrown during auto-mapping when an activity sits inside a multi-instance container in the new model, the multi-instance element's content changed between models (nested MI, changed collection, not same sub-process content), and no explicit mapping exists. Arbitrary movement inside a changed multi-instance container would corrupt instance state.","triggerScenarios":"Migrating a running activity into a multi-instance parent whose structure changed (nested multi-instance added, changed collectionExpression, or altered embedded sub-process content) without providing an explicit activity mapping.","commonSituations":"New model version adds multi-instance to a sub-process containing the running activity; changing the loop collection; nesting MI inside MI; editing the sub-process content of an active MI element.","solutions":["Add an explicit activity mapping (mapping the MI parent) in the migration document","Revert the multi-instance changes in the target model so content matches (hasSameSubProcessContent passes)","Wait until instances exit the changed multi-instance branch, then migrate","Split migration: complete current model branch, deploy compatible intermediate model, then migrate"],"exampleFix":"// before\nruntimeService.createProcessInstanceMigrationBuilder().migrateToProcessDefinition(v2).migrate(id); // MI content changed\n// after\nruntimeService.createProcessInstanceMigrationBuilder().migrateToProcessDefinition(v2)\n    .addActivityMapping(\"stepInMI\", \"stepInMI\").migrate(id);","handlingStrategy":"validation","validationCode":"// detect changed MI parent content before migrating\nFlowElement oldMI = getFlowElementMultiInstanceParentId(oldModel, activityId) != null ? oldModel.getFlowElement(miParentId) : null;\nFlowElement newMI = newModel.getFlowElement(miParentId);\nif (oldMI != null && newMI != null && !hasSameSubProcessContent((SubProcess) oldMI, (SubProcess) newMI)) {\n    // add explicit mapping\n}","typeGuard":null,"tryCatchPattern":"try {\n    migrationBuilder.migrate(instanceId);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"Cannot migrate arbitrarily inside a Multi Instance container\")) {\n        // add explicit activity mapping for the MI parent\n    }\n}","preventionTips":["Freeze multi-instance structure while instances run inside it","Map multi-instance parents explicitly in every migration document","Compare sub-process content between versions in integration tests","Sequence refactors: drain instances first, then deploy changed MI"],"tags":["flowable","migration","multi-instance","auto-mapping"],"backgroundTag":"unsupported-operation","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"}