{"record":{"id":"463049e72a4816c9","repo":"apache/seatunnel","slug":"common-02-463049","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/maxwell/MaxWellJsonSerializationSchema.java","lineNumber":95,"sourceCode":"\n            if (mergeUpdateEventFlag && row.getRowKind() == RowKind.UPDATE_AFTER) {\n                reuse.setField(0, cacheUpdateBeforeRow);\n            } else {\n                reuse.setField(0, null);\n            }\n\n            reuse.setField(1, row);\n            reuse.setField(2, rowKind2String(row.getRowKind()));\n            if (!StringUtils.isEmpty(row.getTableId())) {\n                reuse.setField(3, TablePath.of(row.getTableId()).getDatabaseName());\n                reuse.setField(4, TablePath.of(row.getTableId()).getTableName());\n            }\n            if (row.getOptions() != null && row.getOptions().containsKey(EVENT_TIME.getName())) {\n                reuse.setField(5, row.getOptions().get(EVENT_TIME.getName()));\n            }\n            return jsonSerializer.serialize(reuse);\n        } catch (Throwable t) {\n            throw CommonError.jsonOperationError(FORMAT, row.toString(), t);\n        }\n    }\n\n    private String rowKind2String(RowKind rowKind) {\n        switch (rowKind) {\n            case INSERT:\n            case UPDATE_AFTER:\n                if (mergeUpdateEventFlag && rowKind.equals(RowKind.UPDATE_AFTER)) {\n                    return OP_UPDATE;\n                }\n                return OP_INSERT;\n            case UPDATE_BEFORE:\n            case DELETE:\n                return OP_DELETE;\n            default:\n                throw new SeaTunnelJsonFormatException(\n                        CommonErrorCodeDeprecated.UNSUPPORTED_OPERATION,\n                        String.format(\"Unsupported operation %s for row kind.\", rowKind));","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/maxwell/MaxWellJsonSerializationSchema.java#L77-L113","documentation":"MaxWellJsonSerializationSchema.serialize wraps any Throwable from building the Maxwell envelope row and JSON-serializing it into jsonOperationError. The offending SeaTunnelRow's toString is embedded. It means the row does not match the Maxwell JSON row type (database/table/type/ts/data/old/xid style fields) or Jackson cannot serialize a value.","triggerScenarios":"serialize(SeaTunnelRow) receives a row whose arity or field types differ from the Maxwell schema built by createJsonRowType, or whose EVENT_TIME option / data fields are not JSON-serializable.","commonSituations":"Using a Maxwell-format sink after a transform altered field count/types; event-time option holding an unsupported object; mismatch between declared database schema and actual incoming rows; null reuse-row state after a failed earlier serialize.","solutions":["Compare row.toString() with the Maxwell JSON schema and fix the producing operator so arity/types match","Ensure EVENT_TIME option value is a JSON-serializable scalar (string/long)","Align the database schema passed to the serializer with the real data columns","Write a unit test serializing the exact failing row to pinpoint the non-conforming field"],"exampleFix":"// before: option carries a LocalDateTime\nrow.getOptions().put(\"EVENT_TIME\", LocalDateTime.now());\n// after: store serializable millis\nrow.getOptions().put(\"EVENT_TIME\", System.currentTimeMillis());","handlingStrategy":"validation","validationCode":"if (row.getArity() != maxwellType.getTotalFields()) {\n    throw new IllegalArgumentException(\"Maxwell row arity mismatch: \" + row);\n}\nObject ts = row.getOptions() == null ? null : row.getOptions().get(\"EVENT_TIME\");\nboolean tsOk = ts == null || ts instanceof String || ts instanceof Long;","typeGuard":"boolean matchesMaxwellSchema(SeaTunnelRow row, SeaTunnelRowType t) {\n    return row != null && row.getArity() == t.getTotalFields();\n}","tryCatchPattern":"try {\n    byte[] out = serializer.serialize(row);\n} catch (SeaTunnelRuntimeException e) {\n    log.error(\"Maxwell serialize failed for {}\", row, e);\n    throw e;\n}","preventionTips":["Do not alter field count/types between source and maxwell sink","Store EVENT_TIME as string/long only","Keep declared database schema aligned with real columns","Cover representative rows with serialization unit tests"],"tags":["json","serialization","maxwell","schema"],"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-23T08:17:48.524Z"}