{"record":{"id":"01c526fb756d1e2b","repo":"flowable/flowable-engine","slug":"request-didn-t-contain-a-list-of-variables-to-crea-01c526","errorCode":null,"errorMessage":"Request didn't contain a list of variables to create.","messagePattern":"Request didn't contain a list of variables to create\\.","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":150,"sourceCode":"\n            List<RestVariable> inputVariables = new ArrayList<>();\n            List<RestVariable> resultVariables = new ArrayList<>();\n            result = resultVariables;\n\n            try {\n                @SuppressWarnings(\"unchecked\")\n                List<Object> variableObjects = (List<Object>) objectMapper.readValue(request.getInputStream(), List.class);\n                for (Object restObject : variableObjects) {\n                    RestVariable restVariable = objectMapper.convertValue(restObject, RestVariable.class);\n                    inputVariables.add(restVariable);\n                }\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;","sourceCodeStart":132,"sourceCodeEnd":168,"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#L132-L168","documentation":"FlowableIllegalArgumentException thrown by createTaskVariable when the request body parsed successfully but contained an empty or missing variables list. Creating task variables requires at least one variable in the array. Both a null list and a zero-length list trigger this.","triggerScenarios":"POST /cmmn-runtime/tasks/{taskId}/variables with body {\"variables\":[]} or omitting the variables field entirely.","commonSituations":"Client code building the list from an empty collection/map; filters that removed all variables before sending; template-generated requests with unfilled variables.","solutions":["Ensure at least one variable object is present in the 'variables' array before calling the endpoint","Guard client-side: skip the API call when the variable collection is empty","Fall back to the single-variable endpoint for one variable","Log/validate the payload before sending"],"exampleFix":"// before\n{\"variables\": []}\n// after\n{\"variables\": [{\"name\":\"k\",\"type\":\"string\",\"value\":\"v\"}]}","handlingStrategy":"validation","validationCode":"if (!Array.isArray(vars) || vars.length === 0) throw new Error('refusing to call createTaskVariable with an empty variables list');","typeGuard":"const hasVariables = (vars) => Array.isArray(vars) && vars.length > 0;","tryCatchPattern":"try { await createVariables(payload) } catch (e) { if (/didn't contain a list of variables/.test(e.message)) console.warn('skipping empty variable batch'); throw e; }","preventionTips":["Skip the API call entirely when the variable list is empty client-side","Validate payload before sending","Use the single-variable endpoint when only one variable is set"],"tags":["rest","validation","empty-payload"],"backgroundTag":"empty-required-field","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"}