{"record":{"id":"b887acbb9021c455","repo":"flowable/flowable-engine","slug":"variable-name-is-required-b887ac","errorCode":null,"errorMessage":"Variable name is required","messagePattern":"Variable name is required","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":161,"sourceCode":"                }\n                \n            } catch (Exception e) {\n                throw new FlowableIllegalArgumentException(\"Failed to serialize to a RestVariable instance\", e);\n            }\n\n            if (inputVariables == null || inputVariables.size() == 0) {\n                throw new FlowableIllegalArgumentException(\"Request didn't contain a list of variables to create.\");\n            }\n\n            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);","sourceCodeStart":143,"sourceCodeEnd":179,"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#L143-L179","documentation":"FlowableIllegalArgumentException thrown by createTaskVariable when one of the RestVariable objects in the POST body has no name. The REST API requires every variable entry to carry an explicit name so it can be stored on the task's variable scope. This is a client payload validation failure, not a server fault.","triggerScenarios":"POST to /cmmn-runtime/tasks/{taskId}/variables (or PUT variants routed through createTaskVariable) with a JSON body array where at least one element omits the \"name\" field or sets it to null.","commonSituations":"Hand-written JSON bodies with typos like \"variableName\" instead of \"name\"; programmatically built payloads where a variable object was constructed without a name; clients migrating from other REST APIs with different field names.","solutions":["Ensure every element in the request body array has a non-null \"name\" field","Fix field-name typos so the JSON key is exactly \"name\"","Validate the payload client-side before sending","Send a single variable via the single-variable endpoint if body shape is easier to control"],"exampleFix":"// before\n[{ \"value\": 42, \"type\": \"integer\" }]\n// after\n[{ \"name\": \"count\", \"value\": 42, \"type\": \"integer\" }]","handlingStrategy":"validation","validationCode":"const invalid = variables.some(v => v == null || typeof v.name !== 'string' || v.name.length === 0);\nif (invalid) throw new Error('Every variable in the body requires a non-empty \"name\"');","typeGuard":"function hasName(v) { return v != null && typeof v.name === 'string' && v.name.length > 0; }","tryCatchPattern":"try { await api.post(`/tasks/${taskId}/variables`, body); }\ncatch (e) { if (isFlowableIllegalArgument(e)) fixPayloadAndRetry(e); else throw e; }","preventionTips":["Always include \"name\" in every variable object","Validate payload schema before sending","Use typed client models with required name field","Add unit tests for request body builders"],"tags":["rest","validation","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}