{"record":{"id":"e1ec1a94e4c1fe5a","repo":"flowable/flowable-engine","slug":"a-suspended","errorCode":null,"errorMessage":" a suspended ","messagePattern":" a suspended ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/NeedsActiveTaskCmd.java","lineNumber":57,"sourceCode":"        this.taskId = taskId;\n    }\n\n    @Override\n    public T execute(CommandContext commandContext) {\n\n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId is null\");\n        }\n\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        TaskEntity task = cmmnEngineConfiguration.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(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":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/NeedsActiveTaskCmd.java#L39-L75","documentation":"NeedsActiveTaskCmd.execute() refuses to run the operation on a suspended task, throwing FlowableException with prefix from getSuspendedTaskExceptionPrefix() plus ' a suspended ' + task. The command subclasses define the prefix (e.g. 'Cannot complete'), so the full message reads like 'Cannot complete a suspended TaskEntity ...'. This enforces that active-only task commands are not applied to suspended tasks.","triggerScenarios":"Calling taskService.complete/claim/resolve etc. on a task whose case instance (or scope) was suspended — task.isSuspended() returns true — while the command requires an active task.","commonSituations":"A case instance was suspended by an administrator and users keep acting on its tasks in the UI; batch jobs processing task lists that include tasks from suspended scopes; after undeploying/suspending definitions.","solutions":["Activate the case instance first via CaseRuntimeService.activateCaseInstance(caseInstanceId), then retry the task command","Filter out suspended tasks: taskService.createTaskQuery().suspended().list() tells you which to skip; query with .active() for workable tasks","Catch FlowableException and check the message prefix to surface 'task is suspended' to the user"],"exampleFix":"// before\ntaskService.complete(taskId); // throws: Cannot complete a suspended ...\n// after\ncmmnRuntimeService.activateCaseInstance(caseInstanceId);\ntaskService.complete(taskId);","handlingStrategy":"try-catch","validationCode":"Task t = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (t != null && t.isSuspended()) throw new IllegalStateException(\"Task is suspended: \" + taskId);","typeGuard":null,"tryCatchPattern":"try { taskService.complete(taskId); } catch (FlowableException e) { if (e.getMessage().contains(\"a suspended\")) { /* activate scope or skip task */ } }","preventionTips":["Query only active tasks (createTaskQuery().active()) in user-facing task lists","Track suspension state of case instances in your app and disable actions on their tasks","Provide an admin 'activate case instance' action to unblock suspended tasks"],"tags":["flowable","cmmn","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"}