{"record":{"id":"6a03c6892d13a915","repo":"flowable/flowable-engine","slug":"cannot-resume-task-with-id","errorCode":null,"errorMessage":"Cannot resume task with id '","messagePattern":"Cannot resume task with id '","errorType":"exception","errorClass":"FlowableCdiException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cdi/src/main/java/org/flowable/cdi/BusinessProcess.java","lineNumber":330,"sourceCode":"    }\n\n    // -------------------------------------\n\n    /**\n     * Associates the task with the provided taskId with the current conversation.\n     *\n     * @param taskId the id of the task\n     * @return the resumed task\n     * @throws FlowableCdiException if no such task is found\n     */\n    public Task startTask(String taskId) {\n        Task currentTask = associationManager.getTask();\n        if (currentTask != null && currentTask.getId().equals(taskId)) {\n            return currentTask;\n        }\n        Task task = processEngine.getTaskService().createTaskQuery().taskId(taskId).singleResult();\n        if (task == null) {\n            throw new FlowableCdiException(\"Cannot resume task with id '\" + taskId + \"', no such task.\");\n        }\n        associationManager.setTask(task);\n        associateExecutionById(task.getProcessInstanceId());\n        return task;\n    }\n\n    /**\n     * @see #startTask(String)\n     * <p>\n     * this method allows to start a conversation if no conversation is active\n     */\n    public Task startTask(String taskId, boolean beginConversation) {\n        if (beginConversation) {\n            Conversation conversation = conversationInstance.get();\n            if (conversation.isTransient()) {\n                conversation.begin();\n            }\n        }","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cdi/src/main/java/org/flowable/cdi/BusinessProcess.java#L312-L348","documentation":"startTask resolves a task id via TaskService and throws FlowableCdiException if no such task exists, refusing to resume/associate the conversation with that task. It only proceeds when a queryable, live task matches the id.","triggerScenarios":"Calling businessProcess.startTask(taskId) / setTaskId / setTask with an id of a task that was completed, deleted, or never existed.","commonSituations":"Users completing the same task in two browser tabs; stale links to tasks from finished processes; tests reusing task ids after taskService.complete().","solutions":["Check the task exists before starting: taskService.createTaskQuery().taskId(id).singleResult().","Treat FlowableCdiException as 'task already completed/invalid' and redirect the user appropriately.","Regenerate or reload the task id from a fresh query rather than caching it."],"exampleFix":"// before\nTask t = businessProcess.startTask(taskId); // throws if completed\n// after\nif (taskService.createTaskQuery().taskId(taskId).singleResult() != null) {\n  Task t = businessProcess.startTask(taskId);\n}","handlingStrategy":"try-catch","validationCode":"if (taskService.createTaskQuery().taskId(taskId).singleResult() == null) {\n  // task already completed or invalid\n}","typeGuard":"boolean taskExists(String id) {\n  return taskService.createTaskQuery().taskId(id).count() > 0;\n}","tryCatchPattern":"try {\n  businessProcess.startTask(taskId);\n} catch (FlowableCdiException e) {\n  // treat as task already completed; redirect user\n}","preventionTips":["Disable repeated task-form submissions","Reload task state before rendering forms","Assume stale ids mean the task completed elsewhere"],"tags":["flowable","cdi","task","not-found"],"backgroundTag":"record-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}