{"record":{"id":"3a58e1d41e2b0a8c","repo":"flowable/flowable-engine","slug":"variable-name-is-required-3a58e1","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/TaskVariableBaseResource.java","lineNumber":206,"sourceCode":"                stream.close();\n\n            } else {\n                throw new FlowableContentNotSupportedException(\"Serialized objects are not allowed\");\n            }\n\n            return getVariableFromRequestWithoutAccessCheck(task, variableName, scope, false);\n\n        } catch (IOException ioe) {\n            throw new FlowableIllegalArgumentException(\"Error getting binary variable\", ioe);\n        } catch (ClassNotFoundException ioe) {\n            throw new FlowableContentNotSupportedException(\"The provided body contains a serialized object for which the class was not found: \" + ioe.getMessage());\n        }\n\n    }\n\n    protected RestVariable setSimpleVariable(RestVariable restVariable, Task task, boolean isNew) {\n        if (restVariable.getName() == null) {\n            throw new FlowableIllegalArgumentException(\"Variable name is required\");\n        }\n\n        // Figure out scope, revert to local is omitted\n        RestVariableScope scope = restVariable.getVariableScope();\n        if (scope == null) {\n            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, 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);","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/task/TaskVariableBaseResource.java#L188-L224","documentation":"Thrown by setSimpleVariable when the RestVariable deserialized from the JSON request body has no 'name' field. Every task variable created or updated via the REST API must carry a name. A nameless variable cannot be keyed in the engine's variable store.","triggerScenarios":"POST/PUT to the task variables endpoints with a JSON body element like {\"type\":\"string\",\"value\":\"x\"} missing the 'name' property.","commonSituations":"Hand-written JSON bodies omitting 'name'; clients mapping objects with different key casing (e.g. 'variableName'); programmatically built bodies where the name field was null.","solutions":["Add the 'name' field to each variable object in the request body","Check client serialization key naming (lower-case 'name')","Validate the body payload before sending"],"exampleFix":"// before\n{\"type\":\"string\",\"value\":\"hello\"}\n// after\n{\"name\":\"myVar\",\"type\":\"string\",\"value\":\"hello\"}","handlingStrategy":"validation","validationCode":"const vars = Array.isArray(body.variables) ? body.variables : [body];\nvars.forEach((v, i) => { if (!v || typeof v.name !== 'string' || v.name.length === 0) throw new Error(`variable at index ${i} missing 'name'`); });","typeGuard":"const hasName = (v) => v != null && typeof v === 'object' && typeof v.name === 'string' && v.name.trim() !== '';","tryCatchPattern":"try { await createVariables(body) } catch (e) { if (/Variable name is required/.test(e.message)) console.error('payload variable missing name:', body); throw e; }","preventionTips":["Always include 'name' in each variable object","Use typed client models for RestVariable","Validate request bodies against the REST schema before sending"],"tags":["rest","validation","json","variables"],"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-14T05:17:10.506Z"}