{"record":{"id":"ad9f7fe5c1f4d168","repo":"flowable/flowable-engine","slug":"cannot-convert-event-payload-payloadinstancevalu-ad9f7f","errorCode":null,"errorMessage":"Cannot convert event payload ${payloadInstanceValue} to type 'boolean'","messagePattern":"Cannot convert event payload (.+?) to type 'boolean'","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java","lineNumber":101,"sourceCode":"\n                } else if (EventPayloadTypes.LONG.equals(definitionType)) {\n\n                    if (payloadInstanceValue instanceof Number) {\n                        objectNode.put(payloadInstance.getDefinitionName(), ((Number) payloadInstanceValue).longValue());\n                    } else if (payloadInstanceValue instanceof String) {\n                        objectNode.put(payloadInstance.getDefinitionName(), Long.valueOf((String) payloadInstanceValue));\n                    } else {\n                        throw new FlowableIllegalArgumentException(\"Cannot convert event payload \" + payloadInstanceValue + \" to type 'long'\");\n                    }\n\n                } else if (EventPayloadTypes.BOOLEAN.equals(definitionType)) {\n\n                    if (payloadInstanceValue instanceof Boolean) {\n                        objectNode.put(payloadInstance.getDefinitionName(), (Boolean) payloadInstanceValue);\n                    } else if (payloadInstanceValue instanceof String) {\n                        objectNode.put(payloadInstance.getDefinitionName(), Boolean.valueOf((String) payloadInstanceValue));\n                    }  else {\n                        throw new FlowableIllegalArgumentException(\"Cannot convert event payload \" + payloadInstanceValue + \" to type 'boolean'\");\n                    }\n\n                } else if (EventPayloadTypes.JSON.equals(definitionType)) {\n                    Object jsonValue = payloadInstanceValue;\n                    if (payloadInstanceValue instanceof Supplier<?>) {\n                        Object suppliedValue = ((Supplier<?>) payloadInstanceValue).get();\n                        JsonNode jsonNode = JsonUtil.asJsonNode(suppliedValue, objectMapper, true);\n                        if (jsonNode != null) {\n                            jsonValue = jsonNode;\n                        }\n                    } else {\n                        JsonNode jsonNode = JsonUtil.asJsonNode(jsonValue, objectMapper, true);\n                        if (jsonNode != null) {\n                            jsonValue = jsonNode;\n                        }\n                    }\n                    if (jsonValue instanceof JsonNode) {\n                        objectNode.set(payloadInstance.getDefinitionName(), (JsonNode) jsonValue);","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java#L83-L119","documentation":"FlowableIllegalArgumentException thrown by EventPayloadToJsonStringSerializer.serialize when a payload instance declared as type 'boolean' is neither a Boolean nor a String, so it cannot be converted to a JSON boolean during serialization.","triggerScenarios":"Payload definition declares type 'boolean' but the instance value is an incompatible object (Number, Map, POJO) at serialize time.","commonSituations":"Flags set as Integer 0/1 from database rows; config-driven payloads using non-Boolean types; schema changes without producer updates.","solutions":["Set the payload value as a Boolean (or boolean-parseable String like \"true\"/\"false\").","Convert numeric flags (0/1) to Boolean before publishing.","Change the payload definition type if the value is not boolean-like."],"exampleFix":"// before\npayload.put(\"active\", resultSet.getInt(\"active\")); // 0/1 int\n// after\npayload.put(\"active\", resultSet.getInt(\"active\") == 1);","handlingStrategy":"type-guard","validationCode":"Object v = payloadValue; if (!(v instanceof Boolean) && !(v instanceof String)) { throw new IllegalArgumentException(\"payload 'boolean' value must be Boolean or String\"); }","typeGuard":"boolean isBooleanCompatible(Object v) { return v instanceof Boolean || v instanceof String; }","tryCatchPattern":"try { serializer.serialize(eventInstance); } catch (FlowableIllegalArgumentException e) { LOG.error(\"payload type mismatch for boolean field: \" + e.getMessage()); throw e; }","preventionTips":["Map 0/1 int flags to Boolean explicitly","Never place numeric values in boolean payload fields","Type-check payload builders with compiler-safe value objects"],"tags":["flowable","serialization","type-mismatch","event-payload"],"backgroundTag":"type-mismatch","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}