flowable/flowable-engine · error · FlowableIllegalArgumentException
Cannot convert event payload ${payloadInstanceValue} to type
Error message
Cannot convert event payload ${payloadInstanceValue} to type 'integer' What it means
FlowableIllegalArgumentException thrown by EventPayloadToJsonStringSerializer.serialize when a payload instance declared as type 'integer' is neither a Number nor a String, so it cannot be converted to a JSON int during event payload serialization.
Source
Thrown at modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java:81
} else if (EventPayloadTypes.DOUBLE.equals(definitionType)) {
if (payloadInstanceValue instanceof Number) {
objectNode.put(payloadInstance.getDefinitionName(), ((Number) payloadInstanceValue).doubleValue());
} else if (payloadInstanceValue instanceof String) {
objectNode.put(payloadInstance.getDefinitionName(), Double.valueOf((String) payloadInstanceValue));
} else {
throw new FlowableIllegalArgumentException("Cannot convert event payload " + payloadInstanceValue + " to type 'double'");
}
} else if (EventPayloadTypes.INTEGER.equals(definitionType)) {
if (payloadInstanceValue instanceof Number) {
objectNode.put(payloadInstance.getDefinitionName(), ((Number) payloadInstanceValue).intValue());
} else if (payloadInstanceValue instanceof String) {
objectNode.put(payloadInstance.getDefinitionName(), Integer.valueOf((String) payloadInstanceValue));
} else {
throw new FlowableIllegalArgumentException("Cannot convert event payload " + payloadInstanceValue + " to type 'integer'");
}
} 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));View on GitHub (pinned to d6d39ce1c6)
Solutions
- Set the payload value as an Integer/Number (or integer-parseable String) matching the 'integer' definition.
- Change the payload definition type if the value is not truly an integer.
- Coerce and validate values before event publication.
Example fix
// before
payload.put("count", someObject); // e.g. a Map
// after
payload.put("count", Integer.parseInt(someObject.toString())); Defensive patterns
Strategy: type-guard
Validate before calling
Object v = payloadValue; if (!(v instanceof Number) && !(v instanceof String)) { throw new IllegalArgumentException("payload 'integer' value must be Number or numeric String"); } Type guard
boolean isIntegerCompatible(Object v) { return v instanceof Number || v instanceof String; } Try / catch
try { serializer.serialize(eventInstance); } catch (FlowableIllegalArgumentException e) { LOG.error("payload type mismatch for integer field: " + e.getMessage()); throw e; } Prevention
- Use Integer/Long values for integer-typed payloads
- Avoid putting Maps/POJOs into numeric payload fields
- Add unit tests asserting payload types against definitions
When it happens
Trigger: Payload definition declares type 'integer' but the instance value is an incompatible object (Boolean, Map, POJO, Double-like non-Number, etc.) at serialize time.
Common situations: Publishing events with values of the wrong Java type; loosely typed map-based payload construction; schema changed from string to integer without updating producers.
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/75af8c19e0da2846.
Report an issue: GitHub.