{"record":{"id":"ac16a4fef03d1e30","repo":"apache/seatunnel","slug":"common-02-ac16a4","errorCode":"COMMON-02","errorMessage":"Json JSON convert/parse '<payload>' operation failed.","messagePattern":"Json JSON convert/parse '<payload>' operation failed\\.","errorType":"error_code","errorClass":"SeaTunnelRuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/JsonSerializationSchema.java","lineNumber":93,"sourceCode":"                        .createConverter(checkNotNull(rowType));\n        this.charset = StandardCharsets.UTF_8;\n    }\n\n    {\n        mapper.configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true);\n    }\n\n    @Override\n    public byte[] serialize(SeaTunnelRow row) {\n        if (node == null) {\n            node = mapper.createObjectNode();\n        }\n\n        try {\n            runtimeConverter.convert(mapper, node, row);\n            return mapper.writeValueAsString(node).getBytes(charset);\n        } catch (Throwable t) {\n            throw CommonError.jsonOperationError(FORMAT, row.toString(), t);\n        }\n    }\n\n    public JsonNode convert(SeaTunnelRow row) {\n        if (node == null) {\n            node = mapper.createObjectNode();\n        }\n\n        try {\n            return runtimeConverter.convert(mapper, node, row);\n        } catch (Exception e) {\n            throw CommonError.jsonOperationError(FORMAT, row.toString(), e);\n        }\n    }\n}\n","sourceCodeStart":75,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/JsonSerializationSchema.java#L75-L109","documentation":"The Json serialization schema failed to convert a SeaTunnelRow into a JsonNode and/or write it out as a JSON string. Any Throwable during runtimeConverter.convert(mapper, node, row) or mapper.writeValueAsString triggers COMMON-02 JSON_OPERATION_FAILED carrying row.toString() as the payload. Unlike deserialization there is no ignoreParseErrors escape hatch, so this fails the record/job.","triggerScenarios":"JsonSerializationSchema.serialize(SeaTunnelRow row) throws when a field value cannot be mapped by the runtime converter to the target JsonNode (unsupported field type, null in a non-nullable position) or Jackson fails to serialize the node (e.g. NaN/Infinity doubles, cyclic values).","commonSituations":"Sink row contains a type the JSON converter does not support (e.g. unusual Map/Array types); null values where the schema disallows them; floating-point NaN values produced by upstream transforms; charset/serialization edge cases.","solutions":["Inspect row.toString() in the message and fix the offending field value/type upstream before serialization","Ensure the SeaTunnelRowType of the producing source matches types the JSON format supports","Clean/coerce NaN, Infinity, and unsupported nested types in a transform before the sink","Capture the wrapped cause (getCause()) to pinpoint the failing converter"],"exampleFix":"// before\nrow.setField(1, Double.NaN); // writeValueAsString fails\n// after\nrow.setField(1, Double.isNaN(value) ? null : value); // or sanitize upstream","handlingStrategy":"validation","validationCode":"// verify each field value is serializable-safe before serialize()\nfor (int i = 0; i < rowType.getTotalFields(); i++) {\n    Object v = row.getField(i);\n    if (v instanceof Double d && (d.isNaN() || d.isInfinite()))\n        throw new IllegalArgumentException(\"non-serializable double at field \" + rowType.getFieldName(i));\n}","typeGuard":"static boolean isJsonSerializable(SeaTunnelRow row, SeaTunnelRowType rowType) {\n    for (int i = 0; i < rowType.getTotalFields(); i++) {\n        Object v = row.getField(i);\n        if (v == null) continue;\n        if (v instanceof Double d && (d.isNaN() || d.isInfinite())) return false;\n    }\n    return true;\n}","tryCatchPattern":"try {\n    byte[] out = schema.serialize(row);\n} catch (SeaTunnelRuntimeException e) {\n    log.error(\"Serialization failed for row {} cause {}\", row, e.getCause());\n    throw e; // serialization has no skip flag; fix the row\n}","preventionTips":["Sanitize NaN/Infinity doubles upstream","Declare only JSON-supported SeaTunnel types in the row schema","Test serialization of edge-case rows (nulls, nested types) in unit tests","Keep row value classes consistent with declared field types"],"tags":["json","serialization","type-mismatch"],"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"}