flowable/flowable-engine · error · FlowableObjectNotFoundException

No historic process instance found with id:

Error message

No historic process instance found with id: 

What it means

DeleteHistoricProcessInstanceCmd looks up the historic process instance by id in the ACT_HI_PROCINST table; if no row exists it throws FlowableObjectNotFoundException. The engine refuses to delete a historic record that does not exist rather than silently succeeding.

Source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/DeleteHistoricProcessInstanceCmd.java:50

public class DeleteHistoricProcessInstanceCmd implements Command<Object>, Serializable {

    private static final long serialVersionUID = 1L;
    protected String processInstanceId;

    public DeleteHistoricProcessInstanceCmd(String processInstanceId) {
        this.processInstanceId = processInstanceId;
    }

    @Override
    public Object execute(CommandContext commandContext) {
        if (processInstanceId == null) {
            throw new FlowableIllegalArgumentException("processInstanceId is null");
        }
        // Check if process instance is still running
        HistoricProcessInstanceEntity instance = CommandContextUtil.getHistoricProcessInstanceEntityManager(commandContext).findById(processInstanceId);

        if (instance == null) {
            throw new FlowableObjectNotFoundException("No historic process instance found with id: " + processInstanceId, HistoricProcessInstance.class);
        }
        if (instance.isDeleted()) {
            return null;
        }
        if (instance.getEndTime() == null) {
            throw new FlowableException("Process instance is still running, cannot delete " + instance);
        }

        if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, instance.getProcessDefinitionId())) {
            Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();
            compatibilityHandler.deleteHistoricProcessInstance(processInstanceId);
            return null;
        }

        CommandContextUtil.getHistoryManager(commandContext).recordProcessInstanceDeleted(processInstanceId, instance.getProcessDefinitionId(), instance.getTenantId());

        return null;
    }

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Confirm the id refers to a completed process instance recorded in history
  2. Query first with historyService.createHistoricProcessInstanceQuery().processInstanceId(id).singleResult() before deleting
  3. Check you are connected to the database/schema that holds the history data

Example fix

// before
historyService.deleteHistoricProcessInstance(id); // may throw if not found
// after
HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery()
    .processInstanceId(id).singleResult();
if (hpi != null) {
    historyService.deleteHistoricProcessInstance(id);
}
Defensive patterns

Strategy: validation

Validate before calling

HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery()
    .processInstanceId(id).singleResult();
if (hpi == null) {
    logger.warn("No historic process instance for id " + id + ", skipping delete");
    return;
}

Type guard

boolean historicInstanceExists = id -> historyService.createHistoricProcessInstanceQuery()
    .processInstanceId(id).count() > 0;

Try / catch

try {
    historyService.deleteHistoricProcessInstance(id);
} catch (FlowableObjectNotFoundException e) {
    logger.info("Historic process instance already gone: " + id);
}

Prevention

When it happens

Trigger: historyService.deleteHistoricProcessInstance(id) where the id does not match any historic process instance, e.g. the id belongs to a still-running instance (not yet in history), a task-only id, or a different database/schema.

Common situations: Deleting against a wrong datasource, using the runtime instance id after the instance never reached history, cleaned history tables (history level none/audit cleanup), or typos in the id (instanceId vs executionId).

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


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/1082b2789e34bd14. Report an issue: GitHub.