{"record":{"id":"08ce7fb97df11440","repo":"flowable/flowable-engine","slug":"converter-can-only-convert-booleans","errorCode":null,"errorMessage":"Converter can only convert booleans","messagePattern":"Converter can only convert booleans","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/BooleanRestVariableConverter.java","lineNumber":37,"sourceCode":" * @author Frederik Heremans\n */\npublic class BooleanRestVariableConverter implements RestVariableConverter {\n\n    @Override\n    public String getRestTypeName() {\n        return \"boolean\";\n    }\n\n    @Override\n    public Class<?> getVariableType() {\n        return Boolean.class;\n    }\n\n    @Override\n    public Object getVariableValue(EngineRestVariable result) {\n        if (result.getValue() != null) {\n            if (!(result.getValue() instanceof Boolean)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert booleans\");\n            }\n            return result.getValue();\n        }\n        return null;\n    }\n\n    @Override\n    public void convertVariableValue(Object variableValue, EngineRestVariable result) {\n        if (variableValue != null) {\n            if (!(variableValue instanceof Boolean)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert booleans\");\n            }\n            result.setValue(variableValue);\n        } else {\n            result.setValue(null);\n        }\n    }\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/BooleanRestVariableConverter.java#L19-L55","documentation":"BooleanRestVariableConverter reads Boolean engine variables out of an EngineRestVariable in getVariableValue. If the stored value is not a java.lang.Boolean (and not null), the converter cannot interpret it, so FlowableIllegalArgumentException is thrown to prevent silently coercing wrong types.","triggerScenarios":"Converting a REST variable back to an engine variable where the value field contains a non-Boolean (e.g. the string \"true\", an integer, or a number) but this Boolean converter was selected for the variable type.","commonSituations":"REST clients sending quoted booleans (\"true\" as string) with type 'boolean'; deserialization producing String instead of Boolean; custom code putting raw values into EngineRestVariable before conversion.","solutions":["Ensure the REST payload sends a JSON boolean (true/false), not the string \"true\" for boolean-typed variables.","Check the variable 'type' field in the REST request matches the actual value type; use a string converter for \"true\" strings.","If you populate EngineRestVariable yourself, set value only to Boolean.TRUE/Boolean.FALSE or null.","Fix deserialization config so boolean JSON fields map to java.lang.Boolean."],"exampleFix":"// before\n{\"name\":\"active\",\"type\":\"boolean\",\"value\":\"true\"} // String -> throws\n// after\n{\"name\":\"active\",\"type\":\"boolean\",\"value\":true}","handlingStrategy":"type-guard","validationCode":"if (value instanceof String) {\n    value = Boolean.parseBoolean((String) value);\n}","typeGuard":"Boolean asBoolean(Object v) {\n    if (v instanceof Boolean) return (Boolean) v;\n    if (v instanceof String) return Boolean.parseBoolean((String) v);\n    return null;\n}","tryCatchPattern":"try {\n    Object v = converter.getVariableValue(restVariable);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"convert booleans\")) {\n        throw new IllegalArgumentException(\"Boolean variable payload must be a JSON boolean, got: \" + restVariable.getValue(), e);\n    }\n    throw e;\n}","preventionTips":["Always send boolean variables as JSON booleans, never quoted strings.","Verify the 'type' field ('boolean') matches the JSON value type.","Keep deserialization configured so JSON booleans map to java.lang.Boolean.","Avoid setting arbitrary objects into EngineRestVariable before conversion."],"tags":["rest","variables","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-14T11:17:12.474Z"}