flowable/flowable-engine · error · FlowableObjectNotFoundException
Could not find a task instance with id '" + taskId + "'.
Error message
Could not find a task instance with id '" + taskId + "'.
What it means
The history task lookup via historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult() returned null, so Flowable throws FlowableObjectNotFoundException typed to HistoricTaskInstance. It means no historic task with that id exists in the history tables.
Source
Thrown at modules/flowable-rest/src/main/java/org/flowable/rest/service/api/history/HistoricTaskInstanceBaseResource.java:335
*/
protected HistoricTaskInstance getHistoricTaskInstanceFromRequest(String taskId) {
HistoricTaskInstance taskInstance = getHistoricTaskInstanceFromRequestWithoutAccessCheck(taskId);
if (restApiInterceptor != null) {
restApiInterceptor.accessHistoryTaskInfoById(taskInstance);
}
return taskInstance;
}
/**
* Returns the {@link HistoricTaskInstance} that is requested without calling the access interceptor
* Throws the right exceptions when bad request was made or instance was not found.
*/
protected HistoricTaskInstance getHistoricTaskInstanceFromRequestWithoutAccessCheck(String taskId) {
HistoricTaskInstance taskInstance = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
if (taskInstance == null) {
throw new FlowableObjectNotFoundException("Could not find a task instance with id '" + taskId + "'.", HistoricTaskInstance.class);
}
return taskInstance;
}
protected void addTaskVariables(HistoricTaskInstanceQuery taskInstanceQuery, List<QueryVariable> variables) {
for (QueryVariable variable : variables) {
if (variable.getVariableOperation() == null) {
throw new FlowableIllegalArgumentException("Variable operation is missing for variable: " + variable.getName());
}
if (variable.getVariableOperation() != QueryVariableOperation.EXISTS && variable.getVariableOperation() != QueryVariableOperation.NOT_EXISTS) {
if (variable.getValue() == null) {
throw new FlowableIllegalArgumentException("Variable value is missing for variable: " + variable.getName());
}
}
boolean nameLess = variable.getName() == null;
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Confirm the task id via runtime TaskService query if the task is still active
- Query ACT_HI_TASKINST (or the history task query) to verify the id exists in history
- If the task must be historic, ensure history level records tasks ('audit' or higher)
- Check tenant/datasource configuration to ensure you query the engine that owns the task
Example fix
// before
HistoricTaskInstance t = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
historicTaskApi.get(taskId); // throws
// after
HistoricTaskInstance t = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
if (t == null) {
Task active = taskService.createTaskQuery().taskId(taskId).singleResult();
if (active != null) { /* task still running: use runtime endpoints */ }
} Defensive patterns
Strategy: try-catch
Validate before calling
HistoricTaskInstance t = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
if (t == null) { /* task not in history; check runtime taskService */ } Try / catch
try { HistoricTaskInstance t = api.getHistoricTask(taskId); }
catch (FlowableObjectNotFoundException e) { /* fall back to runtime task query */ } Prevention
- Check the runtime task query when the task may still be active
- Validate taskId format/source before the call
- Ensure you are querying the correct engine/tenant datasource
When it happens
Trigger: Any history task endpoint (getHistoricTaskInstanceFromRequestWithoutAccessCheck) with a taskId that does not exist, was never completed/persisted to history, or belongs to a different engine.
Common situations: Task is still active (not yet in history); using the runtime task id against history after the task was deleted without history; pointing at the wrong database/tenant; id truncation in client code.
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 case instance with id '${caseInstanceId}'.
- Historic task instance '' variable value for couldn't be fo
- Historic variable instance '' couldn't be found.
- No historic task instance found with id:
- Could not find a process instance with id '" + processInstan
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/d67eea2e53ccc768.
Report an issue: GitHub.