{"record":{"id":"e929781883524d89","repo":"flowable/flowable-engine","slug":"process-instance-processinstanceid-doesn-t-exist-e92978","errorCode":null,"errorMessage":"process instance <processInstanceId> doesn't exist, the given ID references an execution, though","messagePattern":"process instance <processInstanceId> doesn't exist, the given ID references an execution, though","errorType":"exception","errorClass":"ActivitiObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/SetProcessInstanceNameCmd.java","lineNumber":52,"sourceCode":"        this.name = name;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (processInstanceId == null) {\n            throw new ActivitiIllegalArgumentException(\"processInstanceId is null\");\n        }\n\n        ExecutionEntity execution = commandContext\n                .getExecutionEntityManager()\n                .findExecutionById(processInstanceId);\n\n        if (execution == null) {\n            throw new ActivitiObjectNotFoundException(\"process instance \" + processInstanceId + \" doesn't exist\", ProcessInstance.class);\n        }\n\n        if (!execution.isProcessInstanceType()) {\n            throw new ActivitiObjectNotFoundException(\"process instance \" + processInstanceId +\n                    \" doesn't exist, the given ID references an execution, though\", ProcessInstance.class);\n        }\n\n        if (execution.isSuspended()) {\n            throw new ActivitiException(\"process instance \" + processInstanceId + \" is suspended, cannot set name\");\n        }\n\n        // Actually set the name\n        execution.setName(name);\n\n        // Record the change in history\n        commandContext.getHistoryManager().recordProcessInstanceNameChange(processInstanceId, name);\n\n        return null;\n    }\n\n}\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/SetProcessInstanceNameCmd.java#L34-L70","documentation":"SetProcessInstanceNameCmd throws ActivitiObjectNotFoundException when the given ID resolves to an execution (a child scope such as a subprocess or concurrent branch) rather than a process instance itself. The engine refuses to treat a plain execution as a process instance, so the name is not set. The message clarifies the ID exists but is the wrong entity type.","triggerScenarios":"Calling RuntimeService.setProcessInstanceName(processInstanceId, name) where processInstanceId is actually the ID of a nested execution or concurrent child, not the top-level process instance.","commonSituations":"Passing an executionId from a task or listener callback (Task.getExecutionId()) instead of the process instance ID; IDs fetched from intermediate-scope queries.","solutions":["Resolve the top-level instance ID via execution.getProcessInstanceId() (or getRootProcessInstanceId()) and pass that instead.","Pass task.getProcessInstanceId() rather than task.getExecutionId() from listener/task code.","If you need to mark an inner execution, use process variables — process instance naming only applies to the root instance."],"exampleFix":"// before\nruntimeService.setProcessInstanceName(task.getExecutionId(), \"monthly-run\");\n// after\nruntimeService.setProcessInstanceName(task.getProcessInstanceId(), \"monthly-run\");","handlingStrategy":"validation","validationCode":"Execution exec = runtimeService.createExecutionQuery().executionId(id).singleResult();\nboolean isProcessInstance = exec != null && exec.getParentId() == null;","typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.setProcessInstanceName(executionId, name);\n} catch (ActivitiObjectNotFoundException e) {\n    logger.warn(\"ID {} is not a process instance\", executionId, e);\n}","preventionTips":["Always pass getProcessInstanceId() from tasks/executions, never getExecutionId().","Derive instance IDs from ProcessInstanceQuery, not ExecutionQuery."],"tags":["process-instance","wrong-entity-type","workflow"],"backgroundTag":"invalid-argument-value","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"}