flowable/flowable-engine · error · FlowableIllegalArgumentException

Cannot convert event payload ${payloadInstanceValue} to type

Error message

Cannot convert event payload ${payloadInstanceValue} to type 'double'

What it means

FlowableIllegalArgumentException thrown by EventPayloadToJsonStringSerializer.serialize when a payload instance declared as type 'double' is neither a Number nor a String, so it cannot be converted to a JSON double. This happens while serializing an event payload to JSON for transmission/storage.

Source

Thrown at modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java:71

                continue;
            }

            String definitionType = payloadInstance.getDefinitionType();
            Object payloadInstanceValue = payloadInstance.getValue();

            if (payloadInstanceValue != null) {

                if (EventPayloadTypes.STRING.equals(definitionType)) {
                    objectNode.put(payloadInstance.getDefinitionName(), payloadInstanceValue.toString());

                } 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));

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Set the payload value as a Double/Number (or numeric String) matching the declared 'double' payload type.
  2. Correct the event payload definition if the value is legitimately non-numeric (change type to 'string' or 'json').
  3. Validate/coerce payload values before calling the serializer / publishing the event.

Example fix

// before
EventPayloadInstance p = ...; // declared 'double'
p.setValue("value", complexObject);
// after
p.setValue("value", Double.parseDouble(objectValue.toString()));
Defensive patterns

Strategy: type-guard

Validate before calling

Object v = payloadValue; if (!(v instanceof Number) && !(v instanceof String)) { throw new IllegalArgumentException("payload 'double' value must be Number or numeric String"); }

Type guard

boolean isDoubleCompatible(Object v) { return v instanceof Number || v instanceof String; }

Try / catch

try { serializer.serialize(eventInstance); } catch (FlowableIllegalArgumentException e) { LOG.error("payload type mismatch for double field: " + e.getMessage()); throw e; }

Prevention

When it happens

Trigger: Event payload definition declares type 'double' but the payload instance value is an incompatible object (e.g. Boolean, Map, POJO, or null-valued wrapper) when the event is serialized.

Common situations: Event instance built programmatically with wrong value types; upstream producer sending strings/objects that bypass type coercion; refactored payload models changing a field's Java type.

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


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/b415c3607919ea15. Report an issue: GitHub.