{"record":{"id":"68093304f9db7735","repo":"flowable/flowable-engine","slug":"execution-processinstanceid-doesn-t-exist","errorCode":null,"errorMessage":"execution {processInstanceId} doesn't exist","messagePattern":"execution (.+?) doesn't exist","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/AddCommentCmd.java","lineNumber":78,"sourceCode":"        // Validate task\n        if (taskId != null) {\n            task = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);\n\n            if (task == null) {\n                throw new FlowableObjectNotFoundException(\"Cannot find task with id \" + taskId, Task.class);\n            }\n\n            if (task.isSuspended()) {\n                throw new FlowableException(\"Cannot add a comment to a suspended \" + task);\n            }\n        }\n\n        ExecutionEntity execution = null;\n        if (processInstanceId != null) {\n            execution = processEngineConfiguration.getExecutionEntityManager().findById(processInstanceId);\n\n            if (execution == null) {\n                throw new FlowableObjectNotFoundException(\"execution \" + processInstanceId + \" doesn't exist\", Execution.class);\n            }\n\n            if (execution.isSuspended()) {\n                throw new FlowableException(\"Cannot add a comment to a suspended \" + execution);\n            }\n        }\n\n        String processDefinitionId = null;\n        if (execution != null) {\n            processDefinitionId = execution.getProcessDefinitionId();\n        } else if (task != null) {\n            processDefinitionId = task.getProcessDefinitionId();\n        }\n\n        if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, processDefinitionId)) {\n            Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();\n            return compatibilityHandler.addComment(taskId, processInstanceId, type, message);\n        }","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/AddCommentCmd.java#L60-L96","documentation":"FlowableObjectNotFoundException thrown by AddCommentCmd.execute when a processInstanceId was supplied but no execution with that id exists. The comment is anchored to the process instance, so the command validates its execution before writing.","triggerScenarios":"taskService.addComment(null, processInstanceId, message) with an unknown, ended, or removed process instance id.","commonSituations":"Commenting on a process instance after it completed and runtime data was cleaned; wrong-schema/wrong-engine deployments; passing processDefinitionId or executionId instead of the process instance id.","solutions":["Verify with runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult() != null before commenting.","If the instance has ended, record the note via history APIs or your own audit table instead of addComment.","Confirm the id is a processInstanceId (not an executionId or definitionId).","Ensure the comment and process operations run against the same engine/database."],"exampleFix":"// before\ntaskService.addComment(null, processInstanceId, msg);\n// after\nProcessInstance pi = runtimeService.createProcessInstanceQuery()\n    .processInstanceId(processInstanceId).singleResult();\nif (pi != null) {\n    taskService.addComment(null, processInstanceId, msg);\n}","handlingStrategy":"validation","validationCode":"if (runtimeService.createProcessInstanceQuery()\n        .processInstanceId(processInstanceId).singleResult() == null) {\n    throw new IllegalArgumentException(\"Unknown process instance: \" + processInstanceId);\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskService.addComment(null, processInstanceId, msg);\n} catch (FlowableObjectNotFoundException e) {\n    // instance ended or unknown; record via history/audit store\n}","preventionTips":["Only comment on running instances; use history for completed ones.","Don't confuse executionId/processDefinitionId with processInstanceId.","Keep runtime-data cleanup jobs aware of pending comment operations."],"tags":["flowable","process-instance","comment","not-found"],"backgroundTag":"entity-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"}