flowable/flowable-engine · error · FlowableObjectNotFoundException
No historic task instance found with id:
Error message
No historic task instance found with id:
What it means
Lookup failure in DeleteHistoricTaskInstanceCmd.execute: taskId passed the null check, but no historic task instance exists in the history store with that id (already deleted, or the task never ended/never existed historically).
Source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/DeleteHistoricTaskInstanceCmd.java:50
private static final long serialVersionUID = 1L;
protected String taskId;
public DeleteHistoricTaskInstanceCmd(String taskId) {
this.taskId = taskId;
}
@Override
public Object execute(CommandContext commandContext) {
if (taskId == null) {
throw new FlowableIllegalArgumentException("taskId is null");
}
// Check if task is completed
HistoricTaskInstanceEntity historicTaskInstance = CommandContextUtil.getHistoricTaskService().getHistoricTask(taskId);
if (historicTaskInstance == null) {
throw new FlowableObjectNotFoundException("No historic task instance found with id: " + taskId, HistoricTaskInstance.class);
}
if (historicTaskInstance.getEndTime() == null) {
throw new FlowableException("task does not have an endTime, cannot delete " + historicTaskInstance);
}
CommandContextUtil.getHistoryManager(commandContext).recordHistoricTaskDeleted(historicTaskInstance);
return null;
}
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Verify the task exists via historyService.createHistoricTaskInstanceQuery().taskId(id).singleResult() before deleting
- Check the engine history level is at least 'audit' so tasks are recorded
- Confirm you are using the taskId from the same engine/database as the delete call
Example fix
// before
historyService.deleteHistoricTask(taskId);
// after
HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery()
.taskId(taskId).singleResult();
if (hti != null) {
historyService.deleteHistoricTask(taskId);
} Defensive patterns
Strategy: validation
Validate before calling
HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery()
.taskId(taskId).singleResult();
if (hti == null) {
logger.warn("No historic task for id " + taskId + ", skipping delete");
return;
} Type guard
boolean historicTaskExists = id -> historyService.createHistoricTaskInstanceQuery()
.taskId(id).count() > 0; Try / catch
try {
historyService.deleteHistoricTask(taskId);
} catch (FlowableObjectNotFoundException e) {
logger.info("Historic task already gone: " + taskId);
} Prevention
- Ensure history level is at least 'audit' so tasks are recorded
- Existence-check before delete in cleanup scripts
- Use ids from the same engine/database instance
When it happens
Trigger: historyService.deleteHistoricTask(taskId) with an id that does not match any row in ACT_HI_TASKINST: wrong id, task not yet created in history, history level too low to record tasks, or history cleanup already removed it.
Common situations: Running with history level 'none' or 'activity' so tasks are not recorded, using the runtime taskId after purge/cleanup jobs, or cross-environment ids (test id used against prod engine).
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 + "'.
- Cannot resume task with id '
- Cannot find task with id ${taskId}
- No historic task exists with the given id:
- No case instance found for id
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/26e8792658b35c8c.
Report an issue: GitHub.