{"record":{"id":"e46b6e6d391c12cb","repo":"flowable/flowable-engine","slug":"model-value-is-not-of-type-boolean-but-of-type","errorCode":null,"errorMessage":"Model value is not of type boolean, but of type \" + modelValue.getClass().getName()","messagePattern":"Model value is not of type boolean, but of type \" \\+ modelValue\\.getClass\\(\\)\\.getName\\(\\)","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/form/BooleanFormType.java","lineNumber":53,"sourceCode":"    @Override\n    public Object convertFormValueToModelValue(String propertyValue) {\n        if (propertyValue == null || \"\".equals(propertyValue)) {\n            return null;\n        }\n        return Boolean.valueOf(propertyValue);\n    }\n\n    @Override\n    public String convertModelValueToFormValue(Object modelValue) {\n\n        if (modelValue == null) {\n            return null;\n        }\n\n        if (Boolean.class.isAssignableFrom(modelValue.getClass()) || boolean.class.isAssignableFrom(modelValue.getClass())) {\n            return modelValue.toString();\n        }\n        throw new FlowableIllegalArgumentException(\"Model value is not of type boolean, but of type \" + modelValue.getClass().getName());\n    }\n}\n","sourceCodeStart":35,"sourceCodeEnd":56,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/form/BooleanFormType.java#L35-L56","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Store the variable as a Java Boolean before form conversion (runtimeService.setVariable with Boolean.valueOf(...)).","Change the form property type in the BPMN (e.g. to 'string') if the value is genuinely textual.","Parse strings at the boundary: Boolean.parseBoolean(value) before submitting.","Add a form conversion/validation in custom form code to coerce types before calling FormService."],"exampleFix":"// before\nruntimeService.setVariable(executionId, \"approved\", \"true\"); // String into boolean form type\n// after\nruntimeService.setVariable(executionId, \"approved\", Boolean.valueOf(\"true\"));","handlingStrategy":"type-guard","validationCode":"Object v = runtimeService.getVariable(executionId, \"approved\");\nif (v != null && !(v instanceof Boolean)) {\n    runtimeService.setVariable(executionId, \"approved\", Boolean.parseBoolean(v.toString()));\n}","typeGuard":"static boolean isBooleanValue(Object v) {\n    return v instanceof Boolean || v.getClass() == boolean.class;\n}","tryCatchPattern":"try {\n    formService.getStartFormData(pdId); // triggers conversion\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Model value is not of type boolean\")) {\n        runtimeService.setVariable(executionId, varName, Boolean.valueOf(String.valueOf(rawValue)));\n    } else { throw e; }\n}","preventionTips":["Declare boolean form properties and always store java.lang.Boolean in the variable.","Coerce external-system values (\"true\"/\"1\") at the integration boundary.","Add variable-type assertions in process tests.","Avoid overwriting typed variables with raw request parameters."],"tags":["flowable","forms","type-mismatch","boolean"],"backgroundTag":"type-mismatch","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"}