flowable/flowable-engine · error · FlowableIllegalArgumentException

Model value is not of type boolean, but of type " +…

Error message

Model value is not of type boolean, but of type " + modelValue.getClass().getName()

What it means

BooleanFormType.convertModelValueToFormValue converts a model (variable) value to its form representation and only accepts Boolean/primitive-boolean values. Any other type is rejected with FlowableIllegalArgumentException naming the actual class. It enforces that the form type declared in the BPMN form property matches the variable's Java type.

Solutions

  1. Store the variable as a Java Boolean before form conversion (runtimeService.setVariable with Boolean.valueOf(...)).
  2. Change the form property type in the BPMN (e.g. to 'string') if the value is genuinely textual.
  3. Parse strings at the boundary: Boolean.parseBoolean(value) before submitting.
  4. Add a form conversion/validation in custom form code to coerce types before calling FormService.

Example fix

// before
runtimeService.setVariable(executionId, "approved", "true"); // String into boolean form type
// after
runtimeService.setVariable(executionId, "approved", Boolean.valueOf("true"));
Defensive patterns

Strategy: type-guard

Validate before calling

Object v = runtimeService.getVariable(executionId, "approved");
if (v != null && !(v instanceof Boolean)) {
    runtimeService.setVariable(executionId, "approved", Boolean.parseBoolean(v.toString()));
}

Type guard

static boolean isBooleanValue(Object v) {
    return v instanceof Boolean || v.getClass() == boolean.class;
}

Try / catch

try {
    formService.getStartFormData(pdId); // triggers conversion
} catch (FlowableIllegalArgumentException e) {
    if (e.getMessage().startsWith("Model value is not of type boolean")) {
        runtimeService.setVariable(executionId, varName, Boolean.valueOf(String.valueOf(rawValue)));
    } else { throw e; }
}

Prevention

When it happens

Trigger: FormService.getStartFormData/getTaskFormData rendering or FormPropertyHandler submissions where a form property of type 'boolean' has a variable value of another type (e.g. String "true", Integer 1).

Common situations: Setting the process variable from an external system as a String, XML/config loading variables as strings, version changes where the variable was previously free-typed.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/form/BooleanFormType.java:53

    @Override
    public Object convertFormValueToModelValue(String propertyValue) {
        if (propertyValue == null || "".equals(propertyValue)) {
            return null;
        }
        return Boolean.valueOf(propertyValue);
    }

    @Override
    public String convertModelValueToFormValue(Object modelValue) {

        if (modelValue == null) {
            return null;
        }

        if (Boolean.class.isAssignableFrom(modelValue.getClass()) || boolean.class.isAssignableFrom(modelValue.getClass())) {
            return modelValue.toString();
        }
        throw new FlowableIllegalArgumentException("Model value is not of type boolean, but of type " + modelValue.getClass().getName());
    }
}

View on GitHub (pinned to d6d39ce1c6)