flowable/flowable-engine · error · FlowableIllegalArgumentException

Request didn't contain a list of variables to create.

Error message

Request didn't contain a list of variables to create.

What it means

FlowableIllegalArgumentException thrown by createVariable when, after deserialization, the request contained no variables — the input list is null or empty. The endpoint requires at least one variable to create.

Source

Thrown at modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseVariableResource.java:218

            List<RestVariable> inputVariables = new ArrayList<>();
            List<RestVariable> resultVariables = new ArrayList<>();
            result = resultVariables;

            try {
                @SuppressWarnings("unchecked")
                List<Object> variableObjects = (List<Object>) objectMapper.readValue(request.getInputStream(), List.class);
                for (Object restObject : variableObjects) {
                    RestVariable restVariable = objectMapper.convertValue(restObject, RestVariable.class);
                    inputVariables.add(restVariable);
                }
                
            } catch (Exception e) {
                throw new FlowableIllegalArgumentException("Failed to serialize to a RestVariable instance", e);
            }

            if (inputVariables == null || inputVariables.size() == 0) {
                throw new FlowableIllegalArgumentException("Request didn't contain a list of variables to create.");
            }

            Map<String, Object> variablesToSet = new HashMap<>();
            for (RestVariable var : inputVariables) {
                if (var.getName() == null) {
                    throw new FlowableIllegalArgumentException("Variable name is required");
                }

                Object actualVariableValue = restResponseFactory.getVariableValue(var);
                variablesToSet.put(var.getName(), actualVariableValue);
            }

            if (!variablesToSet.isEmpty()) {
                variableInterceptor.createVariables(variablesToSet);
                Map<String, Object> setVariables = null;
                if (variableType == CmmnRestResponseFactory.VARIABLE_PLAN_ITEM || scope == RestVariableScope.LOCAL) {
                    if (async) {
                        runtimeService.setLocalVariablesAsync(instanceId, variablesToSet);

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Include at least one variable object in the JSON array body.
  2. Guard client code to skip the call when the variables map is empty.
  3. Verify the request body is not stripped or transformed to empty by middleware.

Example fix

// before
if (vars.size() > 0) {} // request still sent when empty
curl -X POST .../variables -d '[]'
// after
if (!vars.isEmpty()) { callRestEndpoint(vars); }
// or send at least one entry: [{"name":"count","type":"integer","value":1}]
Defensive patterns

Strategy: validation

Validate before calling

if (!Array.isArray(vars) || vars.length === 0) {
  throw new Error('Refusing to call createVariables with an empty list');
}

Type guard

function hasVariables(v) { return Array.isArray(v) && v.length > 0; }

Try / catch

try {
  await createVariables(id, vars);
} catch (e) {
  if (/didn't contain a list of variables/.test(e.message)) log.warn('No variables to set; skipping call');
  else throw e;
}

Prevention

When it happens

Trigger: POST .../variables with body [] or "null", or a body that deserialized to an empty list.

Common situations: Client builds the array dynamically and all entries got filtered out; template left placeholder empty array; copying an example request but leaving it empty.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/66899e06e30af8cc. Report an issue: GitHub.