{"record":{"id":"2f5727cc0242beed","repo":"flowable/flowable-engine","slug":"could-not-find-a-task-with-id-2f5727","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-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskBaseResource.java","lineNumber":598,"sourceCode":"     */\n    protected Task getTaskFromRequest(String taskId) {\n        Task task = getTaskFromRequestWithoutAccessCheck(taskId);\n\n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessTaskInfoById(task);\n        }\n        \n        return task;\n    }\n\n    /**\n     * Returns the {@link Task} that is requested without calling the access interceptor\n     * Throws the right exceptions when bad request was made or instance was not found.\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    /**\n     * Returns the {@link HistoricTaskInstance} 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 HistoricTaskInstance getHistoricTaskFromRequest(String taskId) {\n        HistoricTaskInstance task = getHistoricTaskFromRequestWithoutAccessCheck(taskId);\n        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessHistoryTaskInfoById(task);\n        }\n        \n        return task;\n    }","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskBaseResource.java#L580-L616","documentation":"Flowable's REST API throws FlowableObjectNotFoundException when getTaskFromRequestWithoutAccessCheck queries the task service by id and no Task exists with that id. It signals the requested runtime task resource does not exist (or the id is malformed/no longer valid).","triggerScenarios":"Any REST call resolving a task id from the request path (e.g. GET /runtime/tasks/{taskId}, task actions, variables, identity links) where the id does not match an existing runtime task (it may have completed and moved to history, or was deleted).","commonSituations":"Using a historic/completed task's id against the runtime endpoint, stale ids after process completion, wrong tenant/database, or typos in the id copied from another environment.","solutions":["Verify the task id exists via GET /runtime/tasks?taskId=... or the Flowable admin/database before calling task-specific endpoints.","If the task has completed, query the history endpoint (GET /history/historic-task-instances/{taskId}) instead.","Re-fetch the task list to get current ids; the old id may be stale after process completion or deletion.","Check that you are connected to the correct database/tenant where the task was created."],"exampleFix":"// before\nGET /runtime/tasks/12345   // id from a completed process\n// after\nGET /history/historic-task-instances/12345","handlingStrategy":"try-catch","validationCode":"// pre-check\nvar exists = rest.get('/runtime/tasks?taskId=' + taskId).data.size > 0;","typeGuard":"function taskExists(task) { return task != null && typeof task.id === 'string'; }","tryCatchPattern":"try {\n    // task endpoint call\n} catch (FlowableObjectNotFoundException e) {\n    if (e.getMessage().contains(\"Could not find a task with id\")) {\n        // fall back to history endpoint or refresh id\n    } else throw e;\n}","preventionTips":["Refresh task ids before operating on them","Route completed tasks to history endpoints","Check the correct database/tenant is in use"],"tags":["rest-api","flowable","not-found","task"],"backgroundTag":"resource-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"}