{"record":{"id":"ebf27e6fba14d63c","repo":"flowable/flowable-engine","slug":"task-is-not-suspended-so-can-t-be-activated","errorCode":null,"errorMessage":"{task} is not suspended, so can't be activated","messagePattern":"(.+?) is not suspended, so can't be activated","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ActivateTaskCmd.java","lineNumber":59,"sourceCode":"    public Void execute(CommandContext commandContext) {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        \n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId is null\");\n        }\n\n        TaskEntity 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.isDeleted()) {\n            throw new FlowableException(task + \" is already deleted\");\n        }\n\n        if (!task.isSuspended()) {\n            throw new FlowableException(task + \" is not suspended, so can't be activated\");\n        }\n        \n        Clock clock = processEngineConfiguration.getClock();\n        Date updateTime = clock.getCurrentTime();\n        task.setSuspendedTime(null);\n        task.setSuspendedBy(null);\n        if (task.getInProgressStartTime() != null) {\n            task.setState(Task.IN_PROGRESS);\n        } else if (task.getClaimTime() != null) {\n            task.setState(Task.CLAIMED);\n        } else {\n            task.setState(Task.CREATED);\n        }\n        task.setSuspensionState(SuspensionState.ACTIVE.getStateCode());\n        \n        HistoricTaskService historicTaskService = processEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService();\n        historicTaskService.recordTaskInfoChange(task, updateTime, processEngineConfiguration);\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ActivateTaskCmd.java#L41-L77","documentation":"FlowableException thrown by ActivateTaskCmd.execute when the task exists and is not deleted but its suspended flag is false. Activation only makes sense on a suspended task; calling it on an already-active task is rejected.","triggerScenarios":"Calling taskService.activateTask(id) twice, or calling it on a task that was never suspended (e.g. activateProcessInstanceById already re-activated it).","commonSituations":"Idempotency bugs in retry loops; overlapping suspension of process instance, process definition, and task activating each other; concurrent admin scripts.","solutions":["Check task.isSuspended() via taskService.createTaskQuery().taskId(id).singleResult() before activating.","Make the operation idempotent: skip activation when the task is already active.","Avoid stacking suspension at multiple levels; suspend/activate at the process-instance level only when possible.","Catch this FlowableException and treat it as a no-op in idempotent workflows."],"exampleFix":"// before\ntaskService.activateTask(taskId);\n// after\nTask t = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (t != null && t.isSuspended()) {\n    taskService.activateTask(taskId);\n}","handlingStrategy":"validation","validationCode":"Task t = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (t != null && t.isSuspended()) {\n    taskService.activateTask(taskId);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check isSuspended() before activating.","Design retries to be idempotent (skip already-active tasks).","Avoid duplicating suspension at task and process-instance levels."],"tags":["flowable","task","suspension","invalid-state"],"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-14T16:17:12.679Z"}