flowable/flowable-engine · error · FlowableIllegalArgumentException
Cannot convert event payload ${payloadInstanceValue} to type
Error message
Cannot convert event payload ${payloadInstanceValue} to type 'boolean' What it means
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.
Source
Thrown at modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java:101
} else if (EventPayloadTypes.LONG.equals(definitionType)) {
if (payloadInstanceValue instanceof Number) {
objectNode.put(payloadInstance.getDefinitionName(), ((Number) payloadInstanceValue).longValue());
} else if (payloadInstanceValue instanceof String) {
objectNode.put(payloadInstance.getDefinitionName(), Long.valueOf((String) payloadInstanceValue));
} else {
throw new FlowableIllegalArgumentException("Cannot convert event payload " + payloadInstanceValue + " to type 'long'");
}
} else if (EventPayloadTypes.BOOLEAN.equals(definitionType)) {
if (payloadInstanceValue instanceof Boolean) {
objectNode.put(payloadInstance.getDefinitionName(), (Boolean) payloadInstanceValue);
} else if (payloadInstanceValue instanceof String) {
objectNode.put(payloadInstance.getDefinitionName(), Boolean.valueOf((String) payloadInstanceValue));
} else {
throw new FlowableIllegalArgumentException("Cannot convert event payload " + payloadInstanceValue + " to type 'boolean'");
}
} else if (EventPayloadTypes.JSON.equals(definitionType)) {
Object jsonValue = payloadInstanceValue;
if (payloadInstanceValue instanceof Supplier<?>) {
Object suppliedValue = ((Supplier<?>) payloadInstanceValue).get();
JsonNode jsonNode = JsonUtil.asJsonNode(suppliedValue, objectMapper, true);
if (jsonNode != null) {
jsonValue = jsonNode;
}
} else {
JsonNode jsonNode = JsonUtil.asJsonNode(jsonValue, objectMapper, true);
if (jsonNode != null) {
jsonValue = jsonNode;
}
}
if (jsonValue instanceof JsonNode) {
objectNode.set(payloadInstance.getDefinitionName(), (JsonNode) jsonValue);View on GitHub (pinned to d6d39ce1c6)
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.
Example fix
// before
payload.put("active", resultSet.getInt("active")); // 0/1 int
// after
payload.put("active", resultSet.getInt("active") == 1); Defensive patterns
Strategy: type-guard
Validate before calling
Object v = payloadValue; if (!(v instanceof Boolean) && !(v instanceof String)) { throw new IllegalArgumentException("payload 'boolean' value must be Boolean or String"); } Type guard
boolean isBooleanCompatible(Object v) { return v instanceof Boolean || v instanceof String; } Try / catch
try { serializer.serialize(eventInstance); } catch (FlowableIllegalArgumentException e) { LOG.error("payload type mismatch for boolean field: " + e.getMessage()); throw e; } Prevention
- 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
When it happens
Trigger: Payload definition declares type 'boolean' but the instance value is an incompatible object (Number, Map, POJO) at serialize time.
Common situations: Flags set as Integer 0/1 from database rows; config-driven payloads using non-Boolean types; schema changes without producer updates.
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
- Cannot convert event payload ${payloadInstanceValue} to type
- Cannot convert event payload ${payloadInstanceValue} to type
- Cannot convert event payload ${payloadInstanceValue} to type
- Cannot convert event payload ${jsonValue} to type 'json'
- Could not read json event payload
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/ad9f7fe5c1f4d168.
Report an issue: GitHub.