{"record":{"id":"fdd402adb3d19570","repo":"apache/seatunnel","slug":"object-json-deserialization-exception","errorCode":null,"errorMessage":"Object json deserialization exception.","messagePattern":"Object json deserialization exception\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java","lineNumber":263,"sourceCode":"\n        try {\n            return OBJECT_MAPPER.readValue(json, type);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Json parse object exception.\", e);\n        }\n    }\n\n    /**\n     * object to json string\n     *\n     * @param object object\n     * @return json string\n     */\n    public static String toJsonString(Object object) {\n        try {\n            return OBJECT_MAPPER.writeValueAsString(object);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Object json deserialization exception.\", e);\n        }\n    }\n\n    public static ObjectNode parseObject(String text) {\n        return parseObject(text.getBytes(StandardCharsets.UTF_8));\n    }\n\n    public static ObjectNode parseObject(byte[] content) {\n        try {\n            return (ObjectNode) OBJECT_MAPPER.readTree(content);\n        } catch (IOException e) {\n            throw new RuntimeException(\n                    \"String json deserialization exception.\"\n                            + new String(content, StandardCharsets.UTF_8),\n                    e);\n        }\n    }\n","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java#L245-L281","documentation":"JsonUtils.toJsonString(Object) is the single-argument serialization helper. When Jackson fails to write the object as JSON, the exception is wrapped in this RuntimeException with the (slightly misleading) message 'Object json deserialization exception.' even though it is a serialization failure.","triggerScenarios":"Calling JsonUtils.toJsonString(obj) on cyclic object graphs, objects whose getters throw, or types with no registered serializer.","commonSituations":"Persisting or logging POJOs before job submission, serializing engine state objects with back-references, passing objects holding closed streams or stale connections.","solutions":["Open the chained cause — despite the message, this is a serialization (write) failure, typically JsonMappingException","Annotate back-references with @JsonIgnore or use @JsonManagedReference/@JsonBackReference for cycles","Fix or guard getters that throw for closed resources","Convert exotic types to simple DTOs before serializing"],"exampleFix":"// before\nclass Task { Task parent; }\nJsonUtils.toJsonString(task); // StackOverflowError from recursion\n// after\nclass Task { @JsonIgnore Task parent; }\nJsonUtils.toJsonString(task);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    String json = JsonUtils.toJsonString(obj);\n} catch (RuntimeException e) {\n    log.warn(\"serialization failed for {}: {}\", obj.getClass(), e.getCause());\n    json = String.valueOf(obj);\n}","preventionTips":["Note the message is misleading: this is a write/serialization failure; always inspect the cause","Eliminate cyclic references in DTOs","Keep serialization tests for all persisted/logged objects"],"tags":["jackson","serialization","misleading-message"],"backgroundTag":"json-marshal-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"}