{"record":{"id":"05e7c05f30094881","repo":"flowable/flowable-engine","slug":"variable-name-is-already-present-on-exec","errorCode":null,"errorMessage":"Variable '\" + name + \"' is already present on execution '\" + execution.getId() + \"'.","messagePattern":"Variable '\" \\+ name \\+ \"' is already present on execution '\" \\+ execution\\.getId\\(\\) \\+ \"'\\.","errorType":"http","errorClass":"FlowableException","httpStatus":500,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/BaseExecutionVariableResource.java","lineNumber":219,"sourceCode":"        }\n\n        Object actualVariableValue = restResponseFactory.getVariableValue(restVariable);\n        setVariable(execution, restVariable.getName(), actualVariableValue, scope, isNew, async);\n\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 {","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/BaseExecutionVariableResource.java#L201-L237","documentation":"FlowableException thrown in setVariable when creating a variable (isNew=true) that already exists on the execution for the given scope. Creation is reserved for new variables; existing variables must be updated via PUT.","triggerScenarios":"POST /runtime/executions/{executionId}/variables with a variable whose name+scope already exists on that execution.","commonSituations":"Re-running a client that POSTs the same variable set without checking existence; using POST instead of PUT for an update; race between two requests creating the same variable.","solutions":["Use PUT /runtime/executions/{id}/variables/{name} to update an existing variable instead of POST","Check existence first with GET on the variable, or use the upsert semantics of PUT variables collection where supported","Handle duplicate creation in client code with idempotency (update if exists)"],"exampleFix":"// before\nPOST /runtime/executions/123/variables  {\"name\":\"status\",\"value\":\"new\"}  // 2nd time -> error\n// after\nPUT /runtime/executions/123/variables/status  {\"value\":\"new\"}","handlingStrategy":"validation","validationCode":"ResponseEntity<String> existing = rest.getForEntity(base + \"/runtime/executions/\" + id + \"/variables/\" + name, String.class);\nboolean isNew = existing.getStatusCode() == HttpStatus.NOT_FOUND;","typeGuard":"null","tryCatchPattern":"try { client.createExecutionVariable(id, var); } catch (HttpClientErrorException e) { if (e.getRawStatusCode() == 409 || e.getResponseBodyAsString().contains(\"already present\")) { client.updateExecutionVariable(id, var.getName(), var); } }","preventionTips":["Use PUT for updates and POST only for creation","Check variable existence with GET before POST","Make variable-seeding code idempotent"],"tags":["rest","variables","conflict","state"],"backgroundTag":"file-already-exists","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"}