flowable/flowable-engine · error · FlowableIllegalArgumentException
Could not read json event payload
Error message
Could not read json event payload
What it means
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.
Source
Thrown at modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/EventPayloadToJsonStringSerializer.java:125
Object suppliedValue = ((Supplier<?>) payloadInstanceValue).get();
JsonNode jsonNode = JsonUtil.asJsonNode(suppliedValue, objectMapper, true);
if (jsonNode != null) {
jsonValue = jsonNode;
}
} else {
JsonNode jsonNode = JsonUtil.asJsonNode(jsonValue, objectMapper, true);
if (jsonNode != null) {
jsonValue = jsonNode;
}
}
if (jsonValue instanceof JsonNode) {
objectNode.set(payloadInstance.getDefinitionName(), (JsonNode) jsonValue);
} else if (jsonValue instanceof String) {
JsonNode jsonNode;
try {
jsonNode = objectMapper.readTree((String) jsonValue);
} catch (JacksonException e) {
throw new FlowableIllegalArgumentException("Could not read json event payload", e);
}
objectNode.set(payloadInstance.getDefinitionName(), jsonNode);
} else {
throw new FlowableIllegalArgumentException("Cannot convert event payload " + jsonValue + " to type 'json'");
}
} else {
throw new FlowableIllegalArgumentException("Unsupported event payload instance type: " + definitionType);
}
} else {
objectNode.putNull(payloadInstance.getDefinitionName());
}
}
try {
return objectMapper.writeValueAsString(objectNode);
} catch (JacksonException e) {View on GitHub (pinned to d6d39ce1c6)
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).
Example fix
// before
payload.put("data", "{name: 'x',} "); // invalid JSON
// after
ObjectNode node = objectMapper.createObjectNode();
node.put("name", "x");
payload.put("data", node); Defensive patterns
Strategy: validation
Validate before calling
if (jsonString != null) { try { objectMapper.readTree(jsonString); } catch (JacksonException e) { throw new IllegalArgumentException("payload is not valid JSON", e); } } Type guard
boolean isValidJson(String s) { try { objectMapper.readTree(s); return true; } catch (Exception e) { return false; } } Try / catch
try { serializer.serialize(eventInstance); } catch (FlowableIllegalArgumentException e) { LOG.error("invalid json payload: " + e.getCause()); throw e; } Prevention
- Validate JSON strings with readTree before publishing
- Pass JsonNode/ObjectNode values instead of raw Strings
- Guard against truncation from message size limits
When it happens
Trigger: Payload definition type is 'json' and the value is a String that is not valid JSON (malformed XML-ish text, truncated JSON, plain text).
Common situations: Producers sending hand-concatenated JSON; template output with unescaped characters; truncated payloads from message size limits; single-quoted pseudo-JSON strings.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- Cannot convert event payload ${jsonValue} to type 'json'
- Error writing app model to json
- Failed to parse jase
- Cannot convert event payload ${payloadInstanceValue} to type
- Cannot convert event payload ${payloadInstanceValue} to type
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/7e4d67bf457f57b5.
Report an issue: GitHub.