{"record":{"id":"c6efef1496779f2c","repo":"apache/seatunnel","slug":"string-json-deserialization-exception-content","errorCode":null,"errorMessage":"String json deserialization exception.<content>","messagePattern":"String json deserialization exception\\.<content>","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java","lineNumber":275,"sourceCode":"     * @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\n    public static ArrayNode parseArray(String text) {\n        try {\n            return (ArrayNode) OBJECT_MAPPER.readTree(text);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Json deserialization exception.\", e);\n        }\n    }\n\n    /** json serializer */\n    public static class JsonDataSerializer extends JsonSerializer<String> {\n\n        @Override","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java#L257-L293","documentation":"JsonUtils.parseObject(byte[]) parses raw bytes into a Jackson ObjectNode via readTree. On IOException it throws this RuntimeException whose message embeds the full offending content, helping identify bad payloads in logs.","triggerScenarios":"Calling JsonUtils.parseObject(byte[] content) with bytes that are not valid JSON: empty arrays, binary data, truncated network reads, or non-UTF-8 encoded text.","commonSituations":"Parsing HTTP response bodies that contain error HTML, reading partially written files, deserializing messages from a queue where a producer wrote non-JSON data, charset mismatches after transport.","solutions":["Look at the content echoed in the exception message to spot HTML error pages, truncation or binary garbage","Check upstream producers/senders — the payload itself is malformed, so fix at the source","Guard for empty payloads before parsing (return early on null/empty)","If responses can legitimately be non-JSON on failure, check the HTTP status/content-type before parsing"],"exampleFix":"// before\nObjectNode node = JsonUtils.parseObject(responseBody); // may be an HTML error page\n// after\nif (responseBody == null || responseBody.length == 0) { return null; }\nObjectNode node = JsonUtils.parseObject(responseBody);","handlingStrategy":"validation","validationCode":"ObjectNode safeParse(byte[] content) {\n    if (content == null || content.length == 0) return null;\n    try { return JsonUtils.parseObject(content); }\n    catch (RuntimeException e) { log.error(\"unparseable payload: {}\", e.getMessage()); return null; }\n}","typeGuard":null,"tryCatchPattern":"try {\n    ObjectNode node = JsonUtils.parseObject(bytes);\n} catch (RuntimeException e) {\n    // message contains the raw content — route to dead-letter/retry\n    deadLetter.accept(bytes, e);\n}","preventionTips":["Reject empty or obviously non-JSON (HTML/binary) payloads before parsing","Verify producer encodes UTF-8 and only emits JSON","Preserve the echoed content from the exception for debugging/dlq"],"tags":["jackson","deserialization","io"],"backgroundTag":"json-parse-error","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"}