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 GetTaskVariableInstancesCmd.execute when no task exists for the given taskId. The lookup via the task service returns null and the command aborts before assembling the variables map; the variableNames/isLocal parameters are never consulted.
Solutions
- Existence-check with taskService.createTaskQuery().taskId(taskId).count() before fetching variables
- Confirm all nodes/environments point at the shared engine database
- For completed tasks, use historyService.createHistoricTaskInstanceQuery / HistoricVariableInstanceQuery
- Catch FlowableObjectNotFoundException and return an idempotent not-found result in batch workers
Example fix
// before
Map<String, VariableInstance> vars = taskService.getTaskVariableInstances(taskId);
// after
if (taskService.createTaskQuery().taskId(taskId).count() == 0) {
return Collections.emptyMap(); // or throw domain-specific NotFound
}
Map<String, VariableInstance> vars = taskService.getTaskVariableInstances(taskId); Defensive patterns
Strategy: try-catch
Validate before calling
boolean exists = taskService.createTaskQuery().taskId(taskId).count() > 0;
Try / catch
try {
Map<String, VariableInstance> vars = taskService.getTaskVariableInstances(taskId);
} catch (FlowableObjectNotFoundException e) {
respond(404, "Task " + taskId + " does not exist");
} Prevention
- Existence-check tasks before fetching variable maps
- Design idempotent workers that tolerate vanished tasks
- Keep all environments on the same engine database/schema
When it happens
Trigger: taskService.getTaskVariableInstances(taskId) with an id for a task that never existed, was deleted, was completed with runtime data cleared, or lives in another database/tenant; filtering with a variableNames list cannot rescue a missing task.
Common situations: Polling job still processing a task id after process termination; cluster nodes sharing a load balancer but not the same engine database; tests reusing ids from a truncated schema.
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
- task
- task " + taskId + " doesn't exist
- Cannot find task with id " + taskId
- Cannot find task with id " + taskId
- Cannot set global variables on execution
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/353b5231719763da.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTaskVariableInstancesCmd.java:53
protected boolean isLocal;
public GetTaskVariableInstancesCmd(String taskId, Collection<String> variableNames, boolean isLocal) {
this.taskId = taskId;
this.variableNames = variableNames;
this.isLocal = isLocal;
}
@Override
public Map<String, VariableInstance> execute(CommandContext commandContext) {
if (taskId == null) {
throw new FlowableIllegalArgumentException("taskId 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);
}
Map<String, VariableInstance> variables = null;
if (variableNames == null) {
if (isLocal) {
variables = task.getVariableInstancesLocal();
} else {
variables = task.getVariableInstances();
}
} else {
if (isLocal) {
variables = task.getVariableInstancesLocal(variableNames, false);
} else {
variables = task.getVariableInstances(variableNames, false);
}
View on GitHub (pinned to d6d39ce1c6)