{"record":{"id":"0db6df6cfb1d329a","repo":"flowable/flowable-engine","slug":"process-instance-processinstanceid-doesn-t-exist","errorCode":null,"errorMessage":"process instance <processInstanceId> doesn't exist","messagePattern":"process instance <processInstanceId> doesn't exist","errorType":"exception","errorClass":"ActivitiObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/SetProcessInstanceNameCmd.java","lineNumber":48,"sourceCode":"    protected String name;\n\n    public SetProcessInstanceNameCmd(String processInstanceId, String name) {\n        this.processInstanceId = processInstanceId;\n        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;","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/SetProcessInstanceNameCmd.java#L30-L66","documentation":"SetProcessInstanceNameCmd throws ActivitiObjectNotFoundException when no execution entity exists for the supplied processInstanceId. The engine looks up the execution by ID and, finding nothing, cannot set a name on a non-existent process instance, so it aborts before any mutation. ProcessInstance.class is passed as the missing-object type so callers can identify what was not found.","triggerScenarios":"Calling RuntimeService.setProcessInstanceName(processInstanceId, name) with an ID that does not match any row in ACT_RU_EXECUTION, e.g. after the process instance completed or was deleted.","commonSituations":"Stale IDs held by a client after the instance finished; ID taken from history tables (ACT_HI_PROCINST) after cleanup; typo'd or truncated instance ID; instance removed by a concurrent job or deleteProcessInstance call.","solutions":["Verify the processInstanceId exists before calling: runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult() != null.","Check whether the instance already ended; if it finished, the name can no longer be changed (set it at start time via ProcessInstanceBuilder.processInstanceName(name)).","Log and correct the source of the ID — it may come from a stale cache or a history record after cleanup."],"exampleFix":"// before\nruntimeService.setProcessInstanceName(processInstanceId, \"monthly-run\");\n// after\nProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();\nif (pi != null) {\n    runtimeService.setProcessInstanceName(processInstanceId, \"monthly-run\");\n}","handlingStrategy":"validation","validationCode":"boolean exists = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).count() > 0;\nif (!exists) throw new IllegalArgumentException(\"Unknown process instance: \" + processInstanceId);","typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.setProcessInstanceName(processInstanceId, name);\n} catch (ActivitiObjectNotFoundException e) {\n    logger.warn(\"Process instance {} not found; skipping rename\", processInstanceId, e);\n}","preventionTips":["Query ProcessInstanceQuery before mutating.","Prefer setting the name at instance start via ProcessInstanceBuilder.","Treat ended instances as immutable; source IDs from runtime queries, not history after cleanup."],"tags":["process-instance","not-found","workflow"],"backgroundTag":"resource-not-found","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"}