flowable/flowable-engine · error · FlowableObjectNotFoundException

task " + taskId + " doesn't exist

Error message

task " + taskId + " doesn't exist

What it means

FlowableObjectNotFoundException (Task.class) thrown by GetTaskVariableInstanceCmd.execute when the task lookup returns null for the supplied taskId. The command fails before attempting to read any variable instance, so the error always means the task id is unresolvable, not that the variable is missing.

Solutions

  1. Check task existence via a task query before reading variables
  2. Verify DB connectivity/schema and tenant filtering — id may exist in another datasource
  3. Catch FlowableObjectNotFoundException and present a 'task no longer available' message
  4. Read historical variables via historyService.createHistoricVariableInstanceQuery().taskId(...) if the task is finished

Example fix

// before
VariableInstance vi = taskService.getTaskVariableInstance(taskId, name);
// after
Task t = taskService.createTaskQuery().taskId(taskId).singleResult();
if (t == null) {
    return historyService.createHistoricVariableInstanceQuery().taskId(taskId).variableName(name).singleResult();
}
VariableInstance vi = taskService.getTaskVariableInstance(taskId, name);
Defensive patterns

Strategy: try-catch

Validate before calling

boolean exists = taskService.createTaskQuery().taskId(taskId).count() > 0;

Try / catch

try {
    VariableInstance vi = taskService.getTaskVariableInstance(taskId, name);
} catch (FlowableObjectNotFoundException e) {
    respond(404, "Task " + taskId + " not found");
}

Prevention

When it happens

Trigger: taskService.getTaskVariableInstance(taskId, name) or getTaskVariableInstanceLocal with a nonexistent/stale/foreign-database taskId; task completed and removed between query and fetch.

Common situations: UI refreshing variable panels after a task was completed in another session; data migration gaps; ids from archived processes with history level 'none'.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTaskVariableInstanceCmd.java:54

        this.taskId = taskId;
        this.variableName = variableName;
        this.isLocal = isLocal;
    }

    @Override
    public VariableInstance execute(CommandContext commandContext) {
        if (taskId == null) {
            throw new FlowableIllegalArgumentException("taskId is null");
        }
        if (variableName == null) {
            throw new FlowableIllegalArgumentException("variableName is null");
        }

        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
        TaskEntity task = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);

        if (task == null) {
            throw new FlowableObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
        }

        VariableInstance variableEntity;

        if (isLocal) {
            variableEntity = task.getVariableInstanceLocal(variableName, false);
        } else {
            variableEntity = task.getVariableInstance(variableName, false);
        }

        return variableEntity;
    }
}

View on GitHub (pinned to d6d39ce1c6)