{"record":{"id":"a2b5c86407c316c2","repo":"flowable/flowable-engine","slug":"only-allowed-to-update-multiple-variables-in-the-s","errorCode":null,"errorMessage":"Only allowed to update multiple variables in the same scope.","messagePattern":"Only allowed to update multiple variables in the same scope\\.","errorType":"http","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/task/TaskVariableCollectionResource.java","lineNumber":171,"sourceCode":"            RestVariableScope sharedScope = null;\n            RestVariableScope varScope = null;\n            Map<String, Object> variablesToSet = new HashMap<>();\n\n            for (RestVariable var : inputVariables) {\n                // Validate if scopes match\n                varScope = var.getVariableScope();\n                if (var.getName() == null) {\n                    throw new FlowableIllegalArgumentException(\"Variable name is required\");\n                }\n\n                if (varScope == null) {\n                    varScope = RestVariableScope.LOCAL;\n                }\n                if (sharedScope == null) {\n                    sharedScope = varScope;\n                }\n                if (varScope != sharedScope) {\n                    throw new FlowableIllegalArgumentException(\"Only allowed to update multiple variables in the same scope.\");\n                }\n\n                if (hasVariableOnScope(task, var.getName(), varScope)) {\n                    throw new FlowableConflictException(\"Variable '\" + var.getName() + \"' is already present on task '\" + task.getId() + \"'.\");\n                }\n\n                Object actualVariableValue = restResponseFactory.getVariableValue(var);\n                variablesToSet.put(var.getName(), actualVariableValue);\n            }\n\n            if (!variablesToSet.isEmpty()) {\n                if (restApiInterceptor != null) {\n                    restApiInterceptor.createTaskVariables(task, variablesToSet, sharedScope);\n                }\n\n                Map<String, Object> setVariables;\n                if (sharedScope == RestVariableScope.LOCAL) {\n                    taskService.setVariablesLocal(task.getId(), variablesToSet);","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/task/TaskVariableCollectionResource.java#L153-L189","documentation":"FlowableIllegalArgumentException thrown by createTaskVariable when the batch of variables in one request mixes scopes (e.g. some LOCAL, some GLOBAL/CASE). The collection endpoint applies one shared scope to all variables in the request, so all entries must agree. Mixed-scope batches are rejected up-front to avoid partial writes.","triggerScenarios":"POST /cmmn-runtime/tasks/{taskId}/variables with a body where one entry has variableScope \"local\" and another has \"global\" (or \"case\"), so varScope != sharedScope during iteration.","commonSituations":"Bulk-setting variables copied from a mixed-scope map; clients that default one variable's scope field differently from the rest; templates that inject a scope into some entries only.","solutions":["Set the same variableScope value on every variable in the request body","Omit variableScope on all entries so all default to LOCAL","Split the batch into separate requests, one per scope","Set individual variables through the single-variable endpoint with its own scope"],"exampleFix":"// before\n[{ \"name\": \"a\", \"value\": 1, \"variableScope\": \"local\" }, { \"name\": \"b\", \"value\": 2, \"variableScope\": \"global\" }]\n// after\n[{ \"name\": \"a\", \"value\": 1, \"variableScope\": \"local\" }, { \"name\": \"b\", \"value\": 2, \"variableScope\": \"local\" }]","handlingStrategy":"validation","validationCode":"const scopes = new Set(variables.map(v => v.variableScope ?? 'local'));\nif (scopes.size > 1) throw new Error('All variables in one request must share the same scope');","typeGuard":null,"tryCatchPattern":"try { await api.post(`/tasks/${taskId}/variables`, body); }\ncatch (e) { if (/same scope/i.test(e.message)) splitByScopeAndRetry(); else throw e; }","preventionTips":["Normalize variableScope across the batch before sending","Omit scope entirely to default all to LOCAL","Group variables by scope and issue one request per scope"],"tags":["rest","scope","conflict"],"backgroundTag":"conflicting-config-options","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"}