{"record":{"id":"3a2dcbcde23c2d99","repo":"flowable/flowable-engine","slug":"no-task-found-for-taskid","errorCode":null,"errorMessage":"No task found for taskId '","messagePattern":"No task found for taskId '","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTaskFormCmd.java","lineNumber":50,"sourceCode":"/**\n * @author Tom Baeyens\n * @author Joram Barrez\n */\npublic class GetTaskFormCmd implements Command<TaskFormData>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String taskId;\n\n    public GetTaskFormCmd(String taskId) {\n        this.taskId = taskId;\n    }\n\n    @Override\n    public TaskFormData execute(CommandContext commandContext) {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        TaskEntity task = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);\n        if (task == null) {\n            throw new FlowableObjectNotFoundException(\"No task found for taskId '\" + taskId + \"'\", Task.class);\n        }\n        \n        if (task.getProcessDefinitionId() != null && Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) {\n            Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();\n            return compatibilityHandler.getTaskFormData(taskId);\n        }\n\n        FormHandlerHelper formHandlerHelper = processEngineConfiguration.getFormHandlerHelper();\n        TaskFormHandler taskFormHandler = formHandlerHelper.getTaskFormHandlder(task);\n        if (taskFormHandler == null) {\n            throw new FlowableException(\"No taskFormHandler specified for '\" + task + \"'\");\n        }\n\n        return taskFormHandler.createTaskForm(task);\n    }\n\n}\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTaskFormCmd.java#L32-L68","documentation":"GetTaskFormCmd builds the TaskFormData for a task. It first loads the TaskEntity by taskId; if TaskService returns null it throws FlowableObjectNotFoundException(\"No task found for taskId '<id>'\", Task.class), i.e. the id is syntactically fine but no such task exists.","triggerScenarios":"Calling taskService.getTaskForm(taskId) with an unknown, deleted, or wrong-environment taskId.","commonSituations":"Form rendered from a stale/deep link after the task was completed and purged; ids copied between dev/test databases; multi-tenant setup querying the wrong engine.","solutions":["Verify the task exists via taskService.createTaskQuery().taskId(taskId).singleResult() before requesting its form","Catch FlowableObjectNotFoundException and redirect the user to a task list / 'task no longer available' page","Confirm you are querying the same engine/database that owns the task","Check history cleanup policies if tasks are purged shortly after completion"],"exampleFix":"// before\nTaskFormData form = taskService.getTaskForm(taskId); // throws if gone\n// after\nif (taskService.createTaskQuery().taskId(taskId).count() > 0) {\n    TaskFormData form = taskService.getTaskForm(taskId);\n}","handlingStrategy":"try-catch","validationCode":"boolean exists = taskService.createTaskQuery().taskId(taskId).count() > 0;","typeGuard":"boolean taskExists(String taskId) {\n    return taskId != null\n        && taskService.createTaskQuery().taskId(taskId).count() > 0;\n}","tryCatchPattern":"try {\n    TaskFormData form = taskService.getTaskForm(taskId);\n} catch (FlowableObjectNotFoundException e) {\n    // task gone; redirect user to task list\n    form = null;\n}","preventionTips":["Re-verify task existence before rendering forms from links/emails","Handle completed-and-purged tasks gracefully in UI flows"],"tags":["java","flowable","not-found","task","form"],"backgroundTag":"entity-not-found","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"}