{"record":{"id":"9df17ffcd1f0a958","repo":"flowable/flowable-engine","slug":"cannot-convert-event-payload-payloadinstancevalu-9df17f","errorCode":null,"errorMessage":"Cannot convert event payload ${payloadInstanceValue} to type 'long'","messagePattern":"Cannot convert event payload (.+?) to type 'long'","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java","lineNumber":91,"sourceCode":"\n                } else if (EventPayloadTypes.INTEGER.equals(definitionType)) {\n\n                    if (payloadInstanceValue instanceof Number) {\n                        objectNode.put(payloadInstance.getDefinitionName(), ((Number) payloadInstanceValue).intValue());\n                    } else if (payloadInstanceValue instanceof String) {\n                        objectNode.put(payloadInstance.getDefinitionName(), Integer.valueOf((String) payloadInstanceValue));\n                    } else {\n                        throw new FlowableIllegalArgumentException(\"Cannot convert event payload \" + payloadInstanceValue + \" to type 'integer'\");\n                    }\n\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) {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java#L73-L109","documentation":"FlowableIllegalArgumentException thrown by EventPayloadToJsonStringSerializer.serialize when a payload instance declared as type 'long' is neither a Number nor a String, so it cannot be converted to a JSON long during serialization.","triggerScenarios":"Payload definition declares type 'long' but the instance value is an incompatible object type at serialize time.","commonSituations":"Timestamps/IDs passed as non-numeric objects; producers using String-typed big identifiers wrapped in POJOs; payload maps built dynamically with wrong types.","solutions":["Set the payload value as a Long/Number (or numeric String) matching the 'long' definition.","Adjust the payload definition type if the value is not numeric.","Validate types when building the EventInstance payload."],"exampleFix":"// before\npayload.put(\"timestamp\", instantObject);\n// after\npayload.put(\"timestamp\", instantObject.toEpochMilli());","handlingStrategy":"type-guard","validationCode":"Object v = payloadValue; if (!(v instanceof Number) && !(v instanceof String)) { throw new IllegalArgumentException(\"payload 'long' value must be Number or numeric String\"); }","typeGuard":"boolean isLongCompatible(Object v) { return v instanceof Number || v instanceof String; }","tryCatchPattern":"try { serializer.serialize(eventInstance); } catch (FlowableIllegalArgumentException e) { LOG.error(\"payload type mismatch for long field: \" + e.getMessage()); throw e; }","preventionTips":["Convert timestamps/IDs to Long before publishing","Do not wrap long values in custom objects","Validate payload values against definitions at event creation time"],"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"}