{"record":{"id":"0721cfdcec139123","repo":"flowable/flowable-engine","slug":"task-task-getid-does-not-have-a-variable-wi","errorCode":null,"errorMessage":"Task '${task.getId()}' does not have a variable with name: '${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":229,"sourceCode":"            scope = RestVariableScope.LOCAL;\n        }\n\n        Object actualVariableValue = restResponseFactory.getVariableValue(restVariable);\n        setVariable(task, restVariable.getName(), actualVariableValue, scope, isNew);\n\n        return getVariableFromRequestWithoutAccessCheck(task, restVariable.getName(), scope.name(), false);\n    }\n\n    protected void setVariable(Task task, String name, Object value, RestVariableScope scope, boolean isNew) {\n        // Create can only be done on new variables. Existing variables should\n        // be updated using PUT\n        boolean hasVariable = hasVariableOnScope(task, name, scope);\n        if (isNew && hasVariable) {\n            throw new FlowableException(\"Variable '\" + name + \"' is already present on task '\" + task.getId() + \"'.\");\n        }\n\n        if (!isNew && !hasVariable) {\n            throw new FlowableObjectNotFoundException(\"Task '\" + task.getId() + \"' does not have a variable with name: '\" + name + \"'.\", null);\n        }\n\n        if (restApiInterceptor != null) {\n            if (isNew) {\n                restApiInterceptor.createTaskVariables(task, Collections.singletonMap(name, value), scope);\n            } else {\n                restApiInterceptor.updateTaskVariables(task, Collections.singletonMap(name, value), scope);\n            }\n        }\n\n        if (scope == RestVariableScope.LOCAL) {\n            taskService.setVariableLocal(task.getId(), name, value);\n        } else {\n            if (task.getExecutionId() != null) {\n                // Explicitly set on execution, setting non-local variable on\n                // task will override local-variable if exists\n                runtimeService.setVariable(task.getExecutionId(), name, value);\n            } else {","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskVariableBaseResource.java#L211-L247","documentation":"Variable lookup failure in TaskVariableBaseResource.setVariable: while creating/updating, the check shows the task does not have a variable with the given name (in the relevant scope), which the requested operation requires.","triggerScenarios":"PUT /runtime/tasks/{taskId}/variables/{variableName} where the name is absent from the task (or wrong scope: variable is on the execution/global scope while scope=local, or standalone task lacking a global).","commonSituations":"Typo in variable name; variable was created on the process/execution scope but updated with local scope; task completed and its variables were removed; different Flowable version/database where the variable was never set.","solutions":["Correct the variable name in the URL/body","Add \"variableScope\": \"global\" (or local as appropriate) to target the scope where the variable lives","Create the variable with POST if it should exist, or GET /runtime/tasks/{taskId}/variables to list what exists"],"exampleFix":"// before\nPUT /runtime/tasks/123/variables/aprovedAmount  (typo, local scope)\n// after\nPUT /runtime/tasks/123/variables/approvedAmount\n{\"name\": \"approvedAmount\", \"value\": true, \"variableScope\": \"global\"}","handlingStrategy":"validation","validationCode":"const existing = await api.get(`/runtime/tasks/${taskId}/variables`); if (!existing.data.some(v => v.name === name && v.variableScope === scope)) { /* create via POST or fix name/scope */ }","typeGuard":null,"tryCatchPattern":"try { await api.put(`/runtime/tasks/${taskId}/variables/${name}`, body); } catch (e) { if (e.response && e.response.status === 404) { await api.post(`/runtime/tasks/${taskId}/variables`, body); } else { throw e; } }","preventionTips":["List variables (with scopes) before updating","Double-check variable name spelling and the variableScope field","Remember task variables disappear when the task completes"],"tags":["rest-api","not-found","scope"],"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"}