{"record":{"id":"f99fdba3383f3839","repo":"flowable/flowable-engine","slug":"could-not-find-a-task-with-id","errorCode":null,"errorMessage":"Could not find a task with id '","messagePattern":"Could not find a task with id '","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/task/TaskBaseResource.java","lineNumber":569,"sourceCode":"    }\n\n    /**\n     * Returns the {@link Task} that is requested and calls the access interceptor.\n     * Throws the right exceptions when bad request was made or instance was not found.\n     */\n    protected Task getTaskFromRequest(String taskId) {\n        Task task = getTaskFromRequestWithoutAccessCheck(taskId);\n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessTaskInfoById(task);\n        }\n\n        return task;\n    }\n\n    protected Task getTaskFromRequestWithoutAccessCheck(String taskId) {\n        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();\n        if (task == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find a task with id '\" + taskId + \"'.\", Task.class);\n        }\n\n        return task;\n    }\n\n    protected List<Task> getTasksFromRequest(Collection<String> taskIds) {\n        return taskService.createTaskQuery().taskIds(taskIds).list();\n    }\n}\n","sourceCodeStart":551,"sourceCodeEnd":579,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/task/TaskBaseResource.java#L551-L579","documentation":"The requested CMMN task id does not correspond to any task in the engine's ACT_RU_TASK table. getTaskFromRequestWithoutAccessCheck queries taskService.createTaskQuery().taskId(taskId) and, when no task is returned, throws FlowableObjectNotFoundException typed to Task.class.","triggerScenarios":"GET /cmmn-runtime/tasks/{taskId} (or any sub-resource like identity links, variables, comments) with a taskId that does not exist, was already completed/deleted, or belongs to a different engine/database.","commonSituations":"Stale client-side task references after task completion; wrong tenant/database; typo or truncated id; querying a historic (completed) task through the runtime API instead of the history API.","solutions":["Verify the taskId exists via the task list query or the database before fetching","If the task is completed, use the CMMN history task endpoints instead of runtime","Check you are connected to the correct database/tenant where the task was created","Catch FlowableObjectNotFoundException and return 404 to the caller"],"exampleFix":"// before\nTask t = restClient.getTask(\"stale-or-typo-id\");\n// after\nList<TaskResponse> found = restClient.queryTasks(taskQuery().taskId(candidateId));\nif (!found.isEmpty()) { Task t = restClient.getTask(candidateId); }","handlingStrategy":"try-catch","validationCode":"const found = await queryTasks({ taskId: id }); if (found.length === 0) throw new NotFound(id);","typeGuard":null,"tryCatchPattern":"try { task = await getTask(id); } catch (e) { if (e.status === 404 || e instanceof FlowableObjectNotFoundException) { /* fall back to history endpoint or return 404 */ } else { throw e; } }","preventionTips":["Refresh task references after completion/deletion","Use the history API for completed tasks","Verify ids against the correct tenant/database"],"tags":["rest","task","not-found","runtime"],"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-18T11:17:12.947Z"}