{"record":{"id":"d7c846b2ddbab91d","repo":"flowable/flowable-engine","slug":"cannot-execute-operation-task-is-suspended","errorCode":null,"errorMessage":"Cannot execute operation: task is suspended","messagePattern":"Cannot execute operation: task is suspended","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/NeedsActiveTaskCmd.java","lineNumber":56,"sourceCode":"    }\n\n    @Override\n    public T execute(CommandContext commandContext) {\n\n        if (taskId == null) {\n            throw new ActivitiIllegalArgumentException(\"taskId is null\");\n        }\n\n        TaskEntity task = commandContext\n                .getTaskEntityManager()\n                .findTaskById(taskId);\n\n        if (task == null) {\n            throw new ActivitiObjectNotFoundException(\"Cannot find task with id \" + taskId, Task.class);\n        }\n\n        if (task.isSuspended()) {\n            throw new ActivitiException(getSuspendedTaskException());\n        }\n\n        return execute(commandContext, task);\n    }\n\n    /**\n     * Subclasses must implement in this method their normal command logic. The provided task is ensured to be active.\n     */\n    protected abstract T execute(CommandContext commandContext, TaskEntity task);\n\n    /**\n     * Subclasses can override this method to provide a customized exception message that will be thrown when the task is suspended.\n     */\n    protected String getSuspendedTaskException() {\n        return \"Cannot execute operation: task is suspended\";\n    }\n\n}","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/NeedsActiveTaskCmd.java#L38-L74","documentation":"The task exists but is suspended (its process instance or definition was suspended), so NeedsActiveTaskCmd.execute() blocks the operation with getSuspendedTaskException(). User tasks inherit suspension from their process instance/definition; no task-level operation is allowed until activation.","triggerScenarios":"taskService.complete, claim, delegate, resolve, setAssignee, etc. while the owning process instance was suspended via runtimeService.suspendProcessInstanceById or the definition via repositoryService.suspendProcessDefinition... with suspendProcessInstances=true.","commonSituations":"Definition suspended during a maintenance window so all in-flight user tasks freeze; a user completes a task from a stale worklist after an admin suspended the instance; automated claims by bots hitting suspended tasks.","solutions":["Activate the process instance: runtimeService.activateProcessInstanceById(processInstanceId) (or the definition-level activate variant).","Check the task's suspended flag beforehand: task.isSuspended() on the fetched Task, or via the task query, and disable the action in the UI.","If suspension is intentional, defer the task operation (queue it) until the instance is reactivated.","Exclude suspended tasks from worker/bot queries using .suspended().exclude... query filters."],"exampleFix":"// before\ntaskService.claim(taskId, userId);\n\n// after\nTask task = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (task != null && !task.isSuspended()) {\n    taskService.claim(taskId, userId);\n} else if (task != null) {\n    runtimeService.activateProcessInstanceById(task.getProcessInstanceId());\n    taskService.claim(taskId, userId);\n}","handlingStrategy":"validation","validationCode":"Task task = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (task != null && task.isSuspended()) throw new IllegalStateException(\"task suspended: \" + taskId);","typeGuard":null,"tryCatchPattern":"try {\n    taskService.complete(taskId);\n} catch (ActivitiException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"suspended\")) {\n        // defer or notify, or activate the process instance\n    }\n}","preventionTips":["Check task.isSuspended() before enabling task actions in the UI","Exclude suspended tasks from bot/worker queries","Coordinate with ops on suspension windows"],"tags":["activiti","flowable","suspended-task","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-18T11:17:12.947Z"}