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

  1. Fix the variable name in the URL
  2. List GET /runtime/tasks/{taskId}/variables first to confirm the name and scope
  3. Query the correct scope parameter (local vs global) matching where the variable was set
  4. 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

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


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)