flowable/flowable-engine · error · FlowableObjectNotFoundException
Could not find a task with id ''.
Error message
Could not find a task with id ''.
What it means
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).
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.
Example fix
// before GET /runtime/tasks/12345 // id from a completed process // after GET /history/historic-task-instances/12345
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check
var exists = rest.get('/runtime/tasks?taskId=' + taskId).data.size > 0; Type guard
function taskExists(task) { return task != null && typeof task.id === 'string'; } Try / catch
try {
// task endpoint call
} catch (FlowableObjectNotFoundException e) {
if (e.getMessage().contains("Could not find a task with id")) {
// fall back to history endpoint or refresh id
} else throw e;
} Prevention
- Refresh task ids before operating on them
- Route completed tasks to history endpoints
- Check the correct database/tenant is in use
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Could not find a task instance with id '" + taskId + "'.
- Batch part with id ' ' does not have a batch part document.
- Batch with id ' ' does not have a batch document.
- Cannot find task with id
- Cannot find task with id
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/2f5727cc0242beed.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskBaseResource.java:598
*/
protected Task getTaskFromRequest(String taskId) {
Task task = getTaskFromRequestWithoutAccessCheck(taskId);
if (restApiInterceptor != null) {
restApiInterceptor.accessTaskInfoById(task);
}
return task;
}
/**
* Returns the {@link Task} that is requested without calling the access interceptor
* Throws the right exceptions when bad request was made or instance was not found.
*/
protected Task getTaskFromRequestWithoutAccessCheck(String taskId) {
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
if (task == null) {
throw new FlowableObjectNotFoundException("Could not find a task with id '" + taskId + "'.", Task.class);
}
return task;
}
/**
* Returns the {@link HistoricTaskInstance} that is requested and calls the access interceptor.
* Throws the right exceptions when bad request was made or instance was not found.
*/
protected HistoricTaskInstance getHistoricTaskFromRequest(String taskId) {
HistoricTaskInstance task = getHistoricTaskFromRequestWithoutAccessCheck(taskId);
if (restApiInterceptor != null) {
restApiInterceptor.accessHistoryTaskInfoById(task);
}
return task;
}View on GitHub (pinned to d6d39ce1c6)