{"record":{"id":"e573e7c12588a939","repo":"flowable/flowable-engine","slug":"variable-name-is-required-e573e7","errorCode":null,"errorMessage":"Variable name is required","messagePattern":"Variable name is required","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/ExecutionBaseResource.java","lineNumber":215,"sourceCode":"\n    protected Execution getExecutionFromRequest(String executionId) {\n        Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult();\n        if (execution == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find an execution with id '\" + executionId + \"'.\", Execution.class);\n        }\n        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessExecutionInfoById(execution);\n        }\n        \n        return execution;\n    }\n\n    protected Map<String, Object> getVariablesToSet(List<RestVariable> restVariables) {\n        Map<String, Object> variablesToSet = new HashMap<>();\n        for (RestVariable var : restVariables) {\n            if (var.getName() == null) {\n                throw new FlowableIllegalArgumentException(\"Variable name is required\");\n            }\n\n            Object actualVariableValue = restResponseFactory.getVariableValue(var);\n\n            variablesToSet.put(var.getName(), actualVariableValue);\n        }\n        return variablesToSet;\n    }\n}\n","sourceCodeStart":197,"sourceCodeEnd":225,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/ExecutionBaseResource.java#L197-L225","documentation":"FlowableIllegalArgumentException thrown by ExecutionBaseResource.getVariablesToSet when a RestVariable in the request body has a null name. The REST variable-update endpoints require every variable object to identify which process variable it targets via its 'name' field; without it the variable cannot be mapped. This is a client-side request validation error, not a server failure.","triggerScenarios":"POST/PUT to execution or process-instance variable endpoints (e.g. POST /runtime/process-instances/{id}/variables or PUT .../variables/{scope}) whose JSON body array contains an element without a 'name' field, e.g. [{\"value\": 5, \"type\": \"integer\"}].","commonSituations":"Hand-written JSON payloads omitting 'name'; scripts building variable arrays programmatically where a key is null or the field is misspelled ('variableName' instead of 'name'); deserialized RestVariable objects constructed in tests without setting name.","solutions":["Add the 'name' field to every variable object in the request body.","Check for field-name typos: the property must be 'name', not 'variableName' or 'key'.","Validate the payload client-side before sending (filter entries with null/blank names).","If constructing RestVariable objects in Java, call setName(...) before invoking the API."],"exampleFix":"// before\n[{\"value\": 5, \"type\": \"integer\"}]\n// after\n[{\"name\": \"orderCount\", \"value\": 5, \"type\": \"integer\"}]","handlingStrategy":"validation","validationCode":"// JS/TS client-side check before POSTing variables\nconst invalid = variables.filter(v => !v || typeof v.name !== 'string' || v.name.length === 0);\nif (invalid.length > 0) throw new Error('Every variable requires a non-empty \"name\" field');","typeGuard":"function hasName(v: unknown): v is { name: string; [k: string]: unknown } {\n  return typeof v === 'object' && v !== null && typeof (v as any).name === 'string' && (v as any).name.length > 0;\n}","tryCatchPattern":"try {\n  await restClient.post(`/runtime/process-instances/${id}/variables`, variables);\n} catch (e) {\n  if (e.response && e.response.status === 400 && /Variable name is required/.test(e.response.data && e.response.data.message || '')) {\n    console.error('Payload contains a variable without a name:', variables.filter(v => !v.name));\n  }\n  throw e;\n}","preventionTips":["Always include 'name' in every variable object of REST payloads.","Build payloads from a validated map (Object.entries) so names cannot be dropped.","Write a shared payload serializer for Flowable variables instead of hand-writing JSON.","Add a unit test asserting every variable in generated payloads has a name."],"tags":["rest-api","validation","variables","flowable"],"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"}