{"record":{"id":"b555e32e4ba0afec","repo":"flowable/flowable-engine","slug":"cannot-add-a-comment-to-a-suspended-execution","errorCode":null,"errorMessage":"Cannot add a comment to a suspended {execution}","messagePattern":"Cannot add a comment to a suspended (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/AddCommentCmd.java","lineNumber":82,"sourceCode":"            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        }\n\n        String userId = Authentication.getAuthenticatedUserId();\n        CommentEntity comment = processEngineConfiguration.getCommentEntityManager().create();\n        comment.setUserId(userId);","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/AddCommentCmd.java#L64-L100","documentation":"FlowableException thrown by AddCommentCmd.execute when the process instance execution exists but is suspended. Comments cannot be added to suspended process instances; the instance must be activated first.","triggerScenarios":"taskService.addComment(null, processInstanceId, message) while the instance is suspended via runtimeService.suspendProcessInstanceById or a suspended process definition.","commonSituations":"Workflow paused for maintenance or business hold while integrations keep posting comments; scheduled comment jobs overlapping a suspension window.","solutions":["Activate the process instance first: runtimeService.activateProcessInstanceById(processInstanceId), then add the comment.","If suspension came from the process definition, activate the definition: runtimeService.activateProcessInstanceByKey(key).","Check execution.isSuspended() (processInstanceQuery().suspended()/active()) before commenting.","Catch FlowableException and defer/queue comments until the instance is active."],"exampleFix":"// before\ntaskService.addComment(null, processInstanceId, msg);\n// after\nif (runtimeService.createProcessInstanceQuery()\n        .processInstanceId(processInstanceId).active().singleResult() != null) {\n    taskService.addComment(null, processInstanceId, msg);\n} else {\n    runtimeService.activateProcessInstanceById(processInstanceId);\n    taskService.addComment(null, processInstanceId, msg);\n}","handlingStrategy":"try-catch","validationCode":"if (runtimeService.createProcessInstanceQuery()\n        .processInstanceId(processInstanceId).suspended().singleResult() != null) {\n    runtimeService.activateProcessInstanceById(processInstanceId);\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskService.addComment(null, processInstanceId, msg);\n} catch (FlowableException e) {\n    // queue and retry after the instance is activated\n    commentQueue.add(new PendingComment(processInstanceId, msg));\n}","preventionTips":["Gate comment integrations on instance active state.","Activate suspended instances before resuming automation.","Use active() filters in process instance queries before writes."],"tags":["flowable","process-instance","suspended","comment"],"backgroundTag":"invalid-state-transition","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"}