{"record":{"id":"7f0769ab9493a024","repo":"flowable/flowable-engine","slug":"cannot-find-the-process-to-migrate-with-id-pro","errorCode":null,"errorMessage":"Cannot find the process to migrate, with id\" + processInstanceId","messagePattern":"Cannot find the process to migrate, with id\" \\+ processInstanceId","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/migration/ProcessInstanceMigrationManagerImpl.java","lineNumber":421,"sourceCode":"        ProcessInstanceQueryImpl processInstanceQueryByProcessDefinitionId = new ProcessInstanceQueryImpl(commandContext, processEngineConfiguration).processDefinitionId(processDefinitionId);\n        Set<String> processInstanceIdsToMigrate = document.getProcessInstanceIdsToMigrate();\n        if (processInstanceIdsToMigrate != null && !processInstanceIdsToMigrate.isEmpty()) {\n            processInstanceQueryByProcessDefinitionId.processInstanceIds(processInstanceIdsToMigrate);\n        }\n        ExecutionEntityManager executionEntityManager = processEngineConfiguration.getExecutionEntityManager();\n        List<ProcessInstance> processInstances = executionEntityManager.findProcessInstanceByQueryCriteria(processInstanceQueryByProcessDefinitionId);\n\n        for (ProcessInstance processInstance : processInstances) {\n            doMigrateProcessInstance(processInstance, processDefinition, document, commandContext);\n        }\n    }\n\n    @Override\n    public void migrateProcessInstance(String processInstanceId, ProcessInstanceMigrationDocument document, CommandContext commandContext) {\n        ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext);\n        ExecutionEntity processExecution = executionEntityManager.findById(processInstanceId);\n        if (processExecution == null) {\n            throw new FlowableException(\"Cannot find the process to migrate, with id\" + processInstanceId);\n        }\n\n        ProcessDefinition procDefToMigrateTo = resolveProcessDefinition(document, commandContext);\n        doMigrateProcessInstance(processExecution, procDefToMigrateTo, document, commandContext);\n    }\n\n    protected void doMigrateProcessInstance(ProcessInstance processInstance, ProcessDefinition procDefToMigrateTo, ProcessInstanceMigrationDocument document, CommandContext commandContext) {\n        LOGGER.debug(\"Start migration of process instance with Id:'{}' to process definition identified by {}\", processInstance.getId(),\n            printProcessDefinitionIdentifierMessage(document));\n\n        if (document.getPreUpgradeScript() != null) {\n            LOGGER.debug(\"Execute pre upgrade process instance script\");\n            executeScript(processInstance, procDefToMigrateTo, document.getPreUpgradeScript(), commandContext);\n        }\n\n        if (document.getPreUpgradeJavaDelegate() != null) {\n            LOGGER.debug(\"Execute pre upgrade process instance script\");\n            executeJavaDelegate(processInstance, procDefToMigrateTo, document.getPreUpgradeJavaDelegate(), commandContext);","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/migration/ProcessInstanceMigrationManagerImpl.java#L403-L439","documentation":"When migrating a single process instance, Flowable looks up the execution entity by the supplied processInstanceId. If no execution entity exists with that id, it throws FlowableException \"Cannot find the process to migrate, with id ...\", since the migration has no instance to operate on.","triggerScenarios":"Calling migrateProcessInstance(processInstanceId, document, commandContext) with an id that doesn't correspond to an existing process instance (already ended, wrong id, or another database/environment).","commonSituations":"Migrating an instance that already completed or was deleted; copy-pasting an id from a different environment; using a task/execution id instead of the process instance id; stale ids after database re-import.","solutions":["Confirm the id exists via RuntimeService.createProcessInstanceQuery().processInstanceId(id).singleResult() before migrating.","Check you are connected to the environment/database where the instance lives.","Ensure the id is the process instance id, not an execution or task id.","If the instance already ended, skip it rather than migrating."],"exampleFix":"// before\nmigrationService.migrateProcessInstance(\"proc-1234\", document); // may not exist\n\n// after\nProcessInstance pi = runtimeService.createProcessInstanceQuery()\n    .processInstanceId(\"proc-1234\").singleResult();\nif (pi != null) {\n    migrationService.migrateProcessInstance(pi.getId(), document);\n}","handlingStrategy":"validation","validationCode":"ProcessInstance pi = runtimeService.createProcessInstanceQuery()\n    .processInstanceId(processInstanceId).singleResult();\nif (pi == null) throw new IllegalArgumentException(\"No process instance: \" + processInstanceId);","typeGuard":null,"tryCatchPattern":"try {\n    migrationService.migrateProcessInstance(processInstanceId, document);\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"Cannot find the process to migrate\")) {\n        logger.warn(\"Skipping missing instance \" + processInstanceId);\n    }\n}","preventionTips":["Query the process instance before migrating to verify existence","Never use task or execution ids in place of the process instance id","Re-check ids when switching between dev/test/prod environments"],"tags":["java","flowable","migration","entity-not-found"],"backgroundTag":"record-not-found","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"}