flowable/flowable-engine · error · FlowableObjectNotFoundException
Task '' does not have a variable with name: ''.
Error message
Task '' does not have a variable with name: ''.
What it means
FlowableObjectNotFoundException thrown by TaskVariableBaseResource when the requested task exists but no variable with the given name exists in the queried scope (global/local/any). The type reference is VariableInstanceEntity.
Solutions
- Fix the variable name in the URL
- List GET /runtime/tasks/{taskId}/variables first to confirm the name and scope
- Query the correct scope parameter (local vs global) matching where the variable was set
- Verify the task/execution still exists and the variable has not been removed
Defensive patterns
Strategy: fallback
Validate before calling
RestVariable[] vars = get("/runtime/tasks/" + taskId + "/variables");
boolean exists = Arrays.stream(vars).anyMatch(v -> v.getName().equals(name)); Try / catch
try { return getTaskVariable(taskId, name); } catch (FlowableObjectNotFoundException e) { return Optional.empty(); } Prevention
- List variables before fetching a specific one
- Verify variable scope (local vs global) when setting and reading
- Centralize variable name constants to avoid typos
When it happens
Trigger: GET /runtime/tasks/{taskId}/variables/{variableName} where variableName is misspelled, was deleted, or only exists in the other scope (e.g. variable is LOCAL but queried with scope=global).
Common situations: Typos in variable names; assuming a variable set on the process instance is visible as a task-local variable; querying after task completion removed local variables.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Case instance ' ' doesn't have a variable with name: ' '.
- Could not find a case instance
- Could not find a plan item instance
- Execution ' ' does not have a variable ' ' in scope
- Historic process instance '" + processInstanceId + "'…
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/a8927efd75ce5e94.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskVariableBaseResource.java:101
variableFound = true;
}
}
} else if (variableScope == RestVariableScope.GLOBAL) {
if (task.getExecutionId() != null && runtimeService.hasVariable(task.getExecutionId(), variableName)) {
value = runtimeService.getVariable(task.getExecutionId(), variableName);
variableFound = true;
}
} else if (variableScope == RestVariableScope.LOCAL) {
if (taskService.hasVariableLocal(taskId, variableName)) {
value = taskService.getVariableLocal(taskId, variableName);
variableFound = true;
}
}
if (!variableFound) {
throw new FlowableObjectNotFoundException("Task '" + taskId + "' does not have a variable with name: '" + variableName + "'.", VariableInstanceEntity.class);
} else {
return restResponseFactory.createRestVariable(variableName, value, variableScope, taskId, RestResponseFactory.VARIABLE_TASK, includeBinary);
}
}
protected boolean hasVariableOnScope(Task task, String variableName, RestVariableScope scope) {
boolean variableFound = false;
if (scope == RestVariableScope.GLOBAL) {
if (task.getExecutionId() != null && runtimeService.hasVariable(task.getExecutionId(), variableName)) {
variableFound = true;
}
} else if (scope == RestVariableScope.LOCAL) {
if (taskService.hasVariableLocal(task.getId(), variableName)) {
variableFound = true;
}
}View on GitHub (pinned to d6d39ce1c6)