{"record":{"id":"4ff02f8fb66a416f","repo":"flowable/flowable-engine","slug":"model-value-is-not-of-type-boolean-but-of-type-4ff02f","errorCode":null,"errorMessage":"Model value is not of type boolean, but of type ${class}","messagePattern":"Model value is not of type boolean, but of type (.+?)","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/form/BooleanFormType.java","lineNumber":54,"sourceCode":"    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())\n                || boolean.class.isAssignableFrom(modelValue.getClass())) {\n            return modelValue.toString();\n        }\n        throw new ActivitiIllegalArgumentException(\"Model value is not of type boolean, but of type \" + modelValue.getClass().getName());\n    }\n}\n","sourceCodeStart":36,"sourceCodeEnd":57,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/form/BooleanFormType.java#L36-L57","documentation":"Thrown by BooleanFormType.convertModelValueToFormValue when the model value is neither Boolean nor boolean, i.e. a form property declared as 'boolean' receives a non-boolean value when rendering it into the form. The message includes the actual class name. This is an ActivitiIllegalArgumentException from the form-type conversion layer.","triggerScenarios":"A form property of type boolean is rendered and the underlying process variable or expression result is e.g. a String \"true\"/\"1\", Integer, or null-like wrapper object instead of a java.lang.Boolean.","commonSituations":"Setting the variable from a REST call or script that sends \"true\" as a String; mapping DB columns/CSV inputs into variables without conversion; older engine versions where the value was stored as String.","solutions":["Set the variable as a genuine Boolean: runtimeService.setVariable(executionId, name, Boolean.TRUE) or pass Boolean in startProcessInstance variables.","Convert String values before assignment: Boolean.parseBoolean(str) (or parse \"1\"/\"0\" explicitly).","Check any delegation/script code that writes the variable to ensure it produces Boolean, not String.","If form rendering should accept truthy strings, add a custom FormType instead of reusing the built-in boolean type."],"exampleFix":"// before\nvariables.put(\"approved\", request.getParameter(\"approved\")); // String\n// after\nvariables.put(\"approved\", Boolean.parseBoolean(request.getParameter(\"approved\")));","handlingStrategy":"type-guard","validationCode":"Object v = runtimeService.getVariable(executionId, \"approved\");\nif (!(v instanceof Boolean)) {\n    throw new IllegalStateException(\"approved must be Boolean, got \" + (v == null ? \"null\" : v.getClass()));\n}","typeGuard":"boolean isBooleanModelValue(Object v) {\n    return v instanceof Boolean;\n}","tryCatchPattern":"try {\n    formService.getTaskFormData(taskId); // triggers form rendering/conversion\n} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Model value is not of type boolean\")) {\n        runtimeService.setVariable(executionId, \"approved\", Boolean.parseBoolean(String.valueOf(rawValue)));\n    }\n}","preventionTips":["Always set boolean form variables as java.lang.Boolean.","Normalize client inputs (\"true\"/\"1\") to Boolean before setting variables.","Review scripts/delegates that write form-backed variables.","Add pre-submit variable type checks in REST layers."],"tags":["forms","type-mismatch","boolean","validation"],"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"}