{"record":{"id":"91f9606a697cbd17","repo":"flowable/flowable-engine","slug":"unsupported-event-payload-instance-type-definit","errorCode":null,"errorMessage":"Unsupported event payload instance type: ${definitionType}","messagePattern":"Unsupported event payload instance type: (.+?)","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java","lineNumber":133,"sourceCode":"                            jsonValue = jsonNode;\n                        }\n                    }\n                    if (jsonValue instanceof JsonNode) {\n                        objectNode.set(payloadInstance.getDefinitionName(), (JsonNode) jsonValue);\n                    } else if (jsonValue instanceof String) {\n                        JsonNode jsonNode;\n                        try {\n                            jsonNode = objectMapper.readTree((String) jsonValue);\n                        } catch (JacksonException e) {\n                            throw new FlowableIllegalArgumentException(\"Could not read json event payload\", e);\n                        }\n                        objectNode.set(payloadInstance.getDefinitionName(), jsonNode);\n                    }  else {\n                        throw new FlowableIllegalArgumentException(\"Cannot convert event payload \" + jsonValue + \" to type 'json'\");\n                    }\n\n                } else {\n                    throw new FlowableIllegalArgumentException(\"Unsupported event payload instance type: \" + definitionType);\n                }\n\n            } else {\n                objectNode.putNull(payloadInstance.getDefinitionName());\n            }\n        }\n\n        try {\n            return objectMapper.writeValueAsString(objectNode);\n        } catch (JacksonException e) {\n            throw new FlowableException(\"Could not serialize event to json string for \" + eventInstance, e);\n        }\n    }\n\n}\n","sourceCodeStart":115,"sourceCodeEnd":149,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java#L115-L149","documentation":"EventPayloadToJsonStringSerializer.serialize converts event payload instance values into a Jackson ObjectNode keyed by payload definition name. Each payload value's Java type must be one of the supported types (String, Number-ish types, Boolean, JsonNode, Map/List convertible types, byte[]/Date per implementation). When payloadInstance.getValue() returns an object whose runtime type is not handled by any instanceof branch, the serializer throws FlowableIllegalArgumentException naming the payload definition type.","triggerScenarios":"Calling serialize(eventInstance) on an event whose payload value was set to an unsupported Java object (e.g. a custom POJO, BigDecimal in an unsupported path, or an enum) instead of String/Boolean/Number/JsonNode/Map/Collection, causing the instanceof chain in serialize to fall through to the final else branch.","commonSituations":"Developers building an InboundEventInstance or payload model programmatically and putting raw domain objects into payload values; upgrading Flowable and relying on a type that a previous version's serializer accepted; populating payloads from reflection/deserialization that yields unexpected types.","solutions":["Convert the payload value to a supported type before setting it: use String, Boolean, Integer/Long/Double, JsonNode (objectMapper.valueToTree(obj)), or Map/List.","If the value is a complex object, serialize it yourself to a JsonNode or JSON string payload so the json branch handles it.","Log/check the failing definitionType reported in the message and compare with the instanceof branches in EventPayloadToJsonStringSerializer to see what is accepted.","If you control the event definition, restrict the payload field type in the event registry model to a supported type so clients cannot set arbitrary objects."],"exampleFix":"// before\npayloadInstance.setValue(new MyCustomDto(\"x\"));\n\n// after\npayloadInstance.setValue(objectMapper.valueToTree(new MyCustomDto(\"x\")));","handlingStrategy":"validation","validationCode":"Object value = payloadInstance.getValue();\nboolean supported = value instanceof String || value instanceof Boolean || value instanceof Number\n        || value instanceof JsonNode || value instanceof Map || value instanceof Collection;\nif (!supported) {\n    throw new IllegalArgumentException(\"Payload '\" + payloadInstance.getDefinitionName()\n            + \"' has unsupported type: \" + (value == null ? \"null\" : value.getClass().getName()));\n}","typeGuard":"boolean isSupportedPayloadType(Object v) {\n    return v instanceof String || v instanceof Boolean || v instanceof Number\n        || v instanceof JsonNode || v instanceof Map || v instanceof Collection;\n}","tryCatchPattern":"try {\n    String json = serializer.serialize(eventInstance);\n} catch (FlowableIllegalArgumentException e) {\n    logger.warn(\"Unsupported payload type in event: {}\", e.getMessage());\n    // convert offending payload to JsonNode and retry\n}","preventionTips":["Only put String, Boolean, Number, JsonNode, Map, or Collection values into event payloads.","Convert domain objects with objectMapper.valueToTree() before assigning to a payload.","Constrain payload field types in the event registry model so arbitrary objects cannot be set."],"tags":["flowable","event-registry","serialization","json","unsupported-type"],"backgroundTag":"unsupported-operation","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"}