{"record":{"id":"7e4d67bf457f57b5","repo":"flowable/flowable-engine","slug":"could-not-read-json-event-payload","errorCode":null,"errorMessage":"Could not read json event payload","messagePattern":"Could not read json event payload","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java","lineNumber":125,"sourceCode":"                        Object suppliedValue = ((Supplier<?>) payloadInstanceValue).get();\n                        JsonNode jsonNode = JsonUtil.asJsonNode(suppliedValue, objectMapper, true);\n                        if (jsonNode != null) {\n                            jsonValue = jsonNode;\n                        }\n                    } else {\n                        JsonNode jsonNode = JsonUtil.asJsonNode(jsonValue, objectMapper, true);\n                        if (jsonNode != null) {\n                            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) {","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java#L107-L143","documentation":"FlowableIllegalArgumentException thrown by EventPayloadToJsonStringSerializer.serialize when a payload declared as type 'json' is a String that Jackson cannot parse into a JsonNode (readTree throws JacksonException). The original Jackson exception is attached as cause.","triggerScenarios":"Payload definition type is 'json' and the value is a String that is not valid JSON (malformed XML-ish text, truncated JSON, plain text).","commonSituations":"Producers sending hand-concatenated JSON; template output with unescaped characters; truncated payloads from message size limits; single-quoted pseudo-JSON strings.","solutions":["Fix the JSON string so it parses (validate with objectMapper.readTree before publishing).","Pass an already-built JsonNode/ObjectNode instead of a raw String to avoid re-parsing.","Check for truncation/encoding issues introduced upstream (size limits, charsets)."],"exampleFix":"// before\npayload.put(\"data\", \"{name: 'x',} \"); // invalid JSON\n// after\nObjectNode node = objectMapper.createObjectNode();\nnode.put(\"name\", \"x\");\npayload.put(\"data\", node);","handlingStrategy":"validation","validationCode":"if (jsonString != null) { try { objectMapper.readTree(jsonString); } catch (JacksonException e) { throw new IllegalArgumentException(\"payload is not valid JSON\", e); } }","typeGuard":"boolean isValidJson(String s) { try { objectMapper.readTree(s); return true; } catch (Exception e) { return false; } }","tryCatchPattern":"try { serializer.serialize(eventInstance); } catch (FlowableIllegalArgumentException e) { LOG.error(\"invalid json payload: \" + e.getCause()); throw e; }","preventionTips":["Validate JSON strings with readTree before publishing","Pass JsonNode/ObjectNode values instead of raw Strings","Guard against truncation from message size limits"],"tags":["flowable","serialization","json","event-payload"],"backgroundTag":"json-parse-error","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"}