flowable/flowable-engine · error · FlowableObjectNotFoundException
No historic task instance found with id:
Error message
No historic task instance found with id:
What it means
DeleteHistoricTaskInstanceCmd throws FlowableObjectNotFoundException when no historic task instance exists for the given taskId in the CMMN engine's history tables. History rows only exist if history is enabled and the task was recorded. The command refuses to proceed because there is nothing to delete.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/DeleteHistoricTaskInstanceCmd.java:51
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.getCmmnHistoryManager(commandContext).recordHistoricTaskDeleted(historicTaskInstance);
return null;
}
}
View on GitHub (pinned to d6d39ce1c6)
Solutions
- Verify the taskId exists via cmmnHistoryService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult() before deleting.
- Check the flowable history level configuration (e.g. 'full'/'audit') to ensure historic tasks are actually recorded.
- Handle the FlowableObjectNotFoundException and treat the delete as a no-op if the record is already gone.
Example fix
// before
historyService.deleteHistoricTaskInstance(taskId);
// after
HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
if (hti != null) {
historyService.deleteHistoricTaskInstance(taskId);
} Defensive patterns
Strategy: validation
Validate before calling
if (taskId == null || historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult() == null) { throw new IllegalStateException("no historic task " + taskId); }
historyService.deleteHistoricTaskInstance(taskId); Try / catch
try { historyService.deleteHistoricTaskInstance(taskId); } catch (FlowableObjectNotFoundException e) { log.warn("Historic task {} already gone", taskId); } Prevention
- Always query for the historic task before deleting.
- Ensure history level records tasks (audit/full), not NONE.
- Treat not-found deletes as idempotent no-ops in cleanup jobs.
When it happens
Trigger: Calling CmmnHistoryService.deleteHistoricTaskInstance(taskId) (via HistoricTaskService.getHistoricTask returning null) with a taskId that never existed, was already deleted, or whose task was never recorded in history (history level off / task still running).
Common situations: Retrying a delete after the first one succeeded; deleting historic tasks from a different engine instance than the one that recorded them; running with history level NONE so no historic task rows are written; typo'ed or stale task IDs from external integrations.
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
- task does not have an endTime, cannot delete
- Cannot find case definition with id
- No historic task exists with the given id:
- No case instance found for id
- Setting transient variable is not supported for read only de
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/7e2259214c388a24.
Report an issue: GitHub.