{"record":{"id":"a8927efd75ce5e94","repo":"flowable/flowable-engine","slug":"task-does-not-have-a-variable-with-name","errorCode":null,"errorMessage":"Task '' does not have a variable with name: ''.","messagePattern":"Task '' does not have a variable with name: ''\\.","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskVariableBaseResource.java","lineNumber":101,"sourceCode":"                    variableFound = true;\n                }\n            }\n\n        } else if (variableScope == RestVariableScope.GLOBAL) {\n            if (task.getExecutionId() != null && runtimeService.hasVariable(task.getExecutionId(), variableName)) {\n                value = runtimeService.getVariable(task.getExecutionId(), variableName);\n                variableFound = true;\n            }\n\n        } else if (variableScope == RestVariableScope.LOCAL) {\n            if (taskService.hasVariableLocal(taskId, variableName)) {\n                value = taskService.getVariableLocal(taskId, variableName);\n                variableFound = true;\n            }\n        }\n\n        if (!variableFound) {\n            throw new FlowableObjectNotFoundException(\"Task '\" + taskId + \"' does not have a variable with name: '\" + variableName + \"'.\", VariableInstanceEntity.class);\n        } else {\n            return restResponseFactory.createRestVariable(variableName, value, variableScope, taskId, RestResponseFactory.VARIABLE_TASK, includeBinary);\n        }\n    }\n\n    protected boolean hasVariableOnScope(Task task, String variableName, RestVariableScope scope) {\n        boolean variableFound = false;\n\n        if (scope == RestVariableScope.GLOBAL) {\n            if (task.getExecutionId() != null && runtimeService.hasVariable(task.getExecutionId(), variableName)) {\n                variableFound = true;\n            }\n\n        } else if (scope == RestVariableScope.LOCAL) {\n            if (taskService.hasVariableLocal(task.getId(), variableName)) {\n                variableFound = true;\n            }\n        }","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskVariableBaseResource.java#L83-L119","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"RestVariable[] vars = get(\"/runtime/tasks/\" + taskId + \"/variables\");\nboolean exists = Arrays.stream(vars).anyMatch(v -> v.getName().equals(name));","typeGuard":null,"tryCatchPattern":"try { return getTaskVariable(taskId, name); } catch (FlowableObjectNotFoundException e) { return Optional.empty(); }","preventionTips":["List variables before fetching a specific one","Verify variable scope (local vs global) when setting and reading","Centralize variable name constants to avoid typos"],"tags":["rest-api","variables","not-found"],"backgroundTag":"record-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}