apache/seatunnel · error · RuntimeException
Failed to serialize EdgeIngressPacket to JSON
Error message
Failed to serialize EdgeIngressPacket to JSON
What it means
PacketPayloadSerializer.serialize builds an EdgeIngressPacket and writes it with Jackson's ObjectMapper. A JsonProcessingException (theoretically unchecked data, broken generators, invalid state) is wrapped in a RuntimeException with the message "Failed to serialize EdgeIngressPacket to JSON" and the original exception as cause. Other failures (e.g. encryption/IV generation) are wrapped with a different WAL-payload message.
Source
Thrown at seatunnel-edge-agent/seatunnel-edge-agent-transport/src/main/java/org/apache/seatunnel/edge/agent/transport/serialize/PacketPayloadSerializer.java:82
ivBase64 = Base64.getEncoder().encodeToString(iv);
} else {
body = compressed;
}
String payloadBase64 = Base64.getEncoder().encodeToString(body);
EdgeIngressPacket packet =
EdgeIngressPacket.builder()
.version(1)
.payload(payloadBase64)
.compression(compressionType.getValue())
.encryption(encryptionType.getValue())
.iv(ivBase64)
.build();
return objectMapper.writeValueAsString(packet);
} catch (JsonProcessingException e) {
throw new RuntimeException("Failed to serialize EdgeIngressPacket to JSON", e);
} catch (Exception e) {
throw new RuntimeException("Failed to serialize WAL payload to packet wire format", e);
}
}
}
View on GitHub (pinned to cf67b549a7)
Solutions
- Inspect the cause (JsonProcessingException) in the stack trace — it names the exact field/type Jackson failed on; fix that payload object (add getters or @JsonIgnore).
- Align Jackson versions across the classpath (check the fat jar for duplicate jackson-databind artifacts).
- Ensure the EdgeIngressPacket and payload classes are on the same build/version as the serializer.
- If you added a custom field type, register a serializer module or make the field a JSON-friendly type (String/byte[] with Base64).
Example fix
// before
public class CustomPayload {
private CustomObject obj; // not JSON-serializable
}
// after
public class CustomPayload {
private String objJson; // pre-serialized JSON string
} Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure the packet is Jackson-friendly before serializing
Objects.requireNonNull(payload, "payload");
try {
new ObjectMapper().writeValueAsString(packet);
} catch (JsonProcessingException probe) {
throw new IllegalStateException("Packet not JSON-serializable: " + probe.getOriginalMessage(), probe);
} Type guard
boolean isJsonFriendly(Object o) {
return o == null || o instanceof String || o instanceof Number
|| o instanceof Boolean || o instanceof byte[] || o instanceof java.util.Map
|| o instanceof java.util.Collection;
} Try / catch
try {
String json = serializer.serialize(payload, key, iv);
} catch (RuntimeException e) {
if (e.getCause() instanceof JsonProcessingException jpe) {
LOG.error("Serialization failed: " + jpe.getOriginalMessage(), e);
}
throw e;
} Prevention
- Keep payload fields JSON-friendly (String, Number, byte[] Base64) or add Jackson serializers for custom types.
- Lock the Jackson version in the shade plugin to avoid duplicate/old jackson-databind on the classpath.
- Add a round-trip test (serialize -> deserialize) for EdgeIngressPacket in CI.
- Log the JsonProcessingException cause message — it pinpoints the offending property.
When it happens
Trigger: Calling serialize on a payload whose resulting EdgeIngressPacket cannot be serialized by Jackson — e.g. a value object without a serializable representation, an ObjectMapper misconfigured for the packet type, or an incompatible Jackson version on the classpath.
Common situations: Classpath conflicts where an older jackson-databind lacks features the packet annotations need; custom payload types added to the packet without Jackson-compatible getters; running with shaded-vs-unshaded Jackson mixtures in the fat jar.
Understand the failure class
Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.
Related errors
- JSON_OPERATION_FAILED
- Failed to serialize WAL payload to packet wire format
- Object to json exception!
- Object json deserialization exception.
- Failed to convert row to JSON
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/c825a0942ab7dd2d.
Report an issue: GitHub.