{"record":{"id":"8537b7d7ebb33c18","repo":"flowable/flowable-engine","slug":"execution-execution-getid-does-not-hav","errorCode":null,"errorMessage":"Execution '\" + execution.getId() + \"' does not have a variable with name: '\" + name + \"'.","messagePattern":"Execution '\" \\+ execution\\.getId\\(\\) \\+ \"' does not have a variable with name: '\" \\+ name \\+ \"'\\.","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/BaseExecutionVariableResource.java","lineNumber":223,"sourceCode":"\n        RestVariable newRestVariable = null;\n        if (!async) {\n            newRestVariable = getVariableFromRequestWithoutAccessCheck(execution, restVariable.getName(), scope, false);\n        }\n        \n        return newRestVariable;\n    }\n\n    protected void setVariable(Execution execution, String name, Object value, RestVariableScope scope, boolean isNew, boolean async) {\n        // Create can only be done on new variables. Existing variables should\n        // be updated using PUT\n        boolean hasVariable = hasVariableOnScope(execution, name, scope);\n        if (isNew && hasVariable) {\n            throw new FlowableException(\"Variable '\" + name + \"' is already present on execution '\" + execution.getId() + \"'.\");\n        }\n\n        if (!isNew && !hasVariable) {\n            throw new FlowableObjectNotFoundException(\"Execution '\" + execution.getId() + \"' does not have a variable with name: '\" + name + \"'.\", null);\n        }\n\n        if (restApiInterceptor != null) {\n            if (isNew) {\n                restApiInterceptor.createExecutionVariables(execution, Collections.singletonMap(name, value), scope);\n            } else {\n                restApiInterceptor.updateExecutionVariables(execution, Collections.singletonMap(name, value), scope);\n            }\n        }\n\n        if (scope == RestVariableScope.LOCAL) {\n            if (async) {\n                runtimeService.setVariableLocalAsync(execution.getId(), name, value);\n            } else {\n                runtimeService.setVariableLocal(execution.getId(), name, value);\n            }\n        } else {\n            String executionId = null;","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/BaseExecutionVariableResource.java#L205-L241","documentation":"FlowableObjectNotFoundException thrown in setVariable when updating a variable (isNew=false) that does not exist on the execution in the requested scope. PUT semantics require the variable to already be present.","triggerScenarios":"PUT /runtime/executions/{id}/variables/{name} (or a PUT collection entry) where no variable with that name exists in local/global scope.","commonSituations":"Variable was never created; variable lives in a different scope (local vs global) than requested; process instance advanced and the variable was removed; typo in variable name.","solutions":["Create the variable first via POST, or switch scope (local vs global) to match where it actually lives","Verify the name and scope with GET /runtime/executions/{id}/variables","Check the variable wasn't deleted when the execution moved to another activity"],"exampleFix":"// before\nPUT /runtime/executions/123/variables/counter {\"value\": 5}  // never created -> error\n// after\nPOST /runtime/executions/123/variables [{\"name\":\"counter\",\"value\":5}]","handlingStrategy":"validation","validationCode":"List<RestVariable> vars = Arrays.asList(rest.getForObject(base + \"/runtime/executions/\" + id + \"/variables\", RestVariable[].class));\nboolean present = vars.stream().anyMatch(v -> v.getName().equals(name) && scopeMatches(v, scope));\nif (!present) throw new IllegalStateException(\"Variable \" + name + \" must be created (POST) before PUT\");","typeGuard":"null","tryCatchPattern":"try { client.updateExecutionVariable(id, name, value); } catch (HttpClientErrorException.NotFound e) { client.createExecutionVariable(id, new RestVariable(name, value, scope)); }","preventionTips":["Confirm scope (local/global) matches where the variable lives","List variables before updating to verify exact names","Create missing variables automatically on NotFound"],"tags":["rest","variables","not-found"],"backgroundTag":"resource-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"}