{"record":{"id":"c825a0942ab7dd2d","repo":"apache/seatunnel","slug":"failed-to-serialize-edgeingresspacket-to-json","errorCode":null,"errorMessage":"Failed to serialize EdgeIngressPacket to JSON","messagePattern":"Failed to serialize EdgeIngressPacket to JSON","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-edge-agent/seatunnel-edge-agent-transport/src/main/java/org/apache/seatunnel/edge/agent/transport/serialize/PacketPayloadSerializer.java","lineNumber":82,"sourceCode":"                ivBase64 = Base64.getEncoder().encodeToString(iv);\n            } else {\n                body = compressed;\n            }\n\n            String payloadBase64 = Base64.getEncoder().encodeToString(body);\n\n            EdgeIngressPacket packet =\n                    EdgeIngressPacket.builder()\n                            .version(1)\n                            .payload(payloadBase64)\n                            .compression(compressionType.getValue())\n                            .encryption(encryptionType.getValue())\n                            .iv(ivBase64)\n                            .build();\n\n            return objectMapper.writeValueAsString(packet);\n        } catch (JsonProcessingException e) {\n            throw new RuntimeException(\"Failed to serialize EdgeIngressPacket to JSON\", e);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Failed to serialize WAL payload to packet wire format\", e);\n        }\n    }\n}\n","sourceCodeStart":64,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-edge-agent/seatunnel-edge-agent-transport/src/main/java/org/apache/seatunnel/edge/agent/transport/serialize/PacketPayloadSerializer.java#L64-L88","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\npublic class CustomPayload {\n    private CustomObject obj; // not JSON-serializable\n}\n\n// after\npublic class CustomPayload {\n    private String objJson; // pre-serialized JSON string\n}","handlingStrategy":"try-catch","validationCode":"// Ensure the packet is Jackson-friendly before serializing\nObjects.requireNonNull(payload, \"payload\");\ntry {\n    new ObjectMapper().writeValueAsString(packet);\n} catch (JsonProcessingException probe) {\n    throw new IllegalStateException(\"Packet not JSON-serializable: \" + probe.getOriginalMessage(), probe);\n}","typeGuard":"boolean isJsonFriendly(Object o) {\n    return o == null || o instanceof String || o instanceof Number\n        || o instanceof Boolean || o instanceof byte[] || o instanceof java.util.Map\n        || o instanceof java.util.Collection;\n}","tryCatchPattern":"try {\n    String json = serializer.serialize(payload, key, iv);\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof JsonProcessingException jpe) {\n        LOG.error(\"Serialization failed: \" + jpe.getOriginalMessage(), e);\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["serialization","json","jackson","runtime"],"backgroundTag":"json-serialization-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}