{"record":{"id":"ad57c077934b6538","repo":"flowable/flowable-engine","slug":"getsuspendedtaskexceptionprefix-a-suspended","errorCode":null,"errorMessage":"getSuspendedTaskExceptionPrefix() + \" a suspended \" + task","messagePattern":"getSuspendedTaskExceptionPrefix\\(\\) \\+ \" a suspended \" \\+ task","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/NeedsActiveTaskCmd.java","lineNumber":61,"sourceCode":"    public T execute(CommandContext commandContext) {\n\n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId is null\");\n        }\n\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\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(getSuspendedTaskExceptionPrefix() + \" a suspended \" + task);\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 getSuspendedTaskExceptionPrefix() {\n        return \"Cannot execute operation for\";\n    }\n\n}","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/NeedsActiveTaskCmd.java#L43-L79","documentation":"NeedsActiveTaskCmd blocks all operations on suspended tasks: after the null/deleted checks, isSuspended() triggers a FlowableException built from getSuspendedTaskExceptionPrefix(). Tasks become suspended when their process instance or process definition is suspended via RuntimeService/RepositoryService.","triggerScenarios":"Claiming, completing, delegating or otherwise modifying a task belonging to a suspended process instance (RuntimeService.suspendProcessInstanceById) or suspended process definition.","commonSituations":"Admin froze a definition/instance during a migration window while users still work their inboxes; batch jobs claim tasks from suspended instances; test environments where fixtures were left suspended.","solutions":["Reactivate the owning process instance/definition (activateProcessInstanceById / activateProcessDefinitionById) and retry the task operation.","Filter the task inbox to exclude suspended tasks: taskService.createTaskQuery().taskId(id).active() or .suspended() checks.","Catch FlowableException and inform the user the task is temporarily frozen pending reactivation.","Schedule user-task maintenance only after draining or freezing the inbox accordingly."],"exampleFix":"// before\ntaskService.claim(taskId, userId);\n// after\nTask task = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (task != null && task.isSuspended()) {\n    throw new IllegalStateException(\"Task is suspended; reactivate the process instance first\");\n}\ntaskService.claim(taskId, userId);","handlingStrategy":"validation","validationCode":"Task task = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (task != null && task.isSuspended()) { throw new IllegalStateException(\"Task is suspended\"); }","typeGuard":null,"tryCatchPattern":"try {\n    taskService.claim(taskId, userId);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"suspended\")) {\n        throw new ServiceUnavailableException(\"Task temporarily suspended\");\n    }\n    throw e;\n}","preventionTips":["Exclude suspended tasks from user inboxes with TaskQuery.active().","Reactivate instances/definitions before resuming task operations.","Communicate maintenance suspension windows to users.","Track suspension state changes via Flowable event listeners."],"tags":["flowable","suspended-task","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-14T11:17:12.474Z"}