{"record":{"id":"3c6f42ffacf1755c","repo":"flowable/flowable-engine","slug":"cannot-add-a-comment-to-a-suspended-task","errorCode":null,"errorMessage":"Cannot add a comment to a suspended {task}","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":69,"sourceCode":"        this.processInstanceId = processInstanceId;\n        this.type = type;\n        this.message = message;\n    }\n\n    @Override\n    public Comment execute(CommandContext commandContext) {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        TaskEntity task = null;\n        // 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) {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/AddCommentCmd.java#L51-L87","documentation":"FlowableException thrown by AddCommentCmd.execute when the referenced task exists but is suspended. The engine forbids mutating suspended tasks, including adding comments, until the task or its process instance is activated.","triggerScenarios":"taskService.addComment(taskId, ...) on a task under a suspended process instance or definition, or after taskService.suspendTask(taskId).","commonSituations":"Administrative suspension (e.g. pending approval fix) while users/automation still try to comment; batch comment jobs running during a suspension window.","solutions":["Activate the task first: taskService.activateTask(taskId), then add the comment.","Activate the owning process instance: runtimeService.activateProcessInstanceById(piId).","Check task.isSuspended() before attempting to comment and defer the comment until re-activation.","Catch FlowableException and queue the comment for delivery after suspension is lifted."],"exampleFix":"// before\ntaskService.addComment(taskId, null, msg);\n// after\nif (taskService.createTaskQuery().taskId(taskId).active().singleResult() != null) {\n    taskService.addComment(taskId, null, msg);\n} else {\n    taskService.activateTask(taskId);\n    taskService.addComment(taskId, null, msg);\n}","handlingStrategy":"try-catch","validationCode":"if (taskService.createTaskQuery().taskId(taskId).suspended().singleResult() != null) {\n    taskService.activateTask(taskId); // or defer the comment\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskService.addComment(taskId, null, msg);\n} catch (FlowableException e) {\n    // queue comment; retry after task is activated\n    commentQueue.add(new PendingComment(taskId, msg));\n}","preventionTips":["Pause commenting workflows during suspension windows.","Check suspended() in the task query before writing.","Activate the task or its process instance before mutation."],"tags":["flowable","task","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"}