{"record":{"id":"e929c9a7b7af4d2b","repo":"apache/flink","slug":"could-not-serialize-row-s-e929c9","errorCode":null,"errorMessage":"Could not serialize row '%s'.","messagePattern":"Could not serialize row '(.+?)'\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/debezium/DebeziumJsonSerializationSchema.java","lineNumber":100,"sourceCode":"                case UPDATE_AFTER:\n                    genericRowData.setField(0, null);\n                    genericRowData.setField(1, rowData);\n                    genericRowData.setField(2, OP_INSERT);\n                    return jsonSerializer.serialize(genericRowData);\n                case UPDATE_BEFORE:\n                case DELETE:\n                    genericRowData.setField(0, rowData);\n                    genericRowData.setField(1, null);\n                    genericRowData.setField(2, OP_DELETE);\n                    return jsonSerializer.serialize(genericRowData);\n                default:\n                    throw new UnsupportedOperationException(\n                            format(\n                                    \"Unsupported operation '%s' for row kind.\",\n                                    rowData.getRowKind()));\n            }\n        } catch (Throwable t) {\n            throw new RuntimeException(format(\"Could not serialize row '%s'.\", rowData), t);\n        }\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) {\n            return true;\n        }\n        if (o == null || getClass() != o.getClass()) {\n            return false;\n        }\n        DebeziumJsonSerializationSchema that = (DebeziumJsonSerializationSchema) o;\n        return Objects.equals(jsonSerializer, that.jsonSerializer);\n    }\n\n    @Override\n    public int hashCode() {\n        return Objects.hash(jsonSerializer);","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/debezium/DebeziumJsonSerializationSchema.java#L82-L118","documentation":"The catch-all in DebeziumJsonSerializationSchema.serialize wraps any Throwable raised while building the [before, after, op] GenericRowData and delegating to the internal JsonRowDataSerializationSchema. The root cause is always in the nested 't' — commonly an unsupported RowKind (default branch), a null field where the physical type is non-nullable, or a JSON conversion failure of a field value.","triggerScenarios":"Any Throwable escaping the serialize() try block: unsupported RowKind; a field value whose type cannot be converted by the generated JsonSerializer (e.g. unexpected object); NullPointerException while reading fields of a RowData that does not match the declared physical row type of the sink table.","commonSituations":"Schema mismatch between the producing job and the debezium-json sink DDL (different field count/order/types); reusing a serialization schema after the sink table schema changed; custom RowData implementations that return null for primitive fields.","solutions":["Read the suppressed cause: the RuntimeException's cause (t) holds the real failure — fix that (RowKind, type, or nullability).","Verify the physical RowType passed to DebeziumJsonSerializationSchema exactly matches the RowData arity and field types produced upstream.","Recreate/refresh the serialization schema after changing the sink table DDL so codegen matches the new schema."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify arity/type agreement before the sink\nObjects.requireNonNull(row, \"row\");\nif (row.getArity() != expectedPhysicalArity) {\n    throw new IllegalArgumentException(\"Row arity \" + row.getArity()\n            + \" != sink arity \" + expectedPhysicalArity);\n}","typeGuard":null,"tryCatchPattern":"try { byte[] out = schema.serialize(row); } catch (RuntimeException e) { log.error(\"serialize failed for row {}, cause: {}\", row, e.getCause()); /* dead-letter */ }","preventionTips":["Log the cause chain, not just the wrapper message.","Rebuild serialization schemas whenever the sink DDL changes."],"tags":["flink","debezium","json","serialization","wrapper-exception"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}