{"record":{"id":"e101c6de051ea206","repo":"apache/flink","slug":"could-not-serialize-row-s-e101c6","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-csv/src/main/java/org/apache/flink/formats/csv/CsvRowDataSerializationSchema.java","lineNumber":183,"sourceCode":"                                JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES, false);\n                        return csvMapper;\n                    });\n        }\n    }\n\n    @Override\n    public byte[] serialize(RowData row) {\n        if (root == null) {\n            root = csvMapper.createObjectNode();\n            converterContext =\n                    new RowDataToCsvConverters.RowDataToCsvConverter\n                            .RowDataToCsvFormatConverterContext(csvMapper, root);\n        }\n        try {\n            runtimeConverter.convert(row, converterContext);\n            return objectWriter.writeValueAsBytes(root);\n        } catch (Throwable t) {\n            throw new RuntimeException(String.format(\"Could not serialize row '%s'.\", row), t);\n        }\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (o == null || o.getClass() != this.getClass()) {\n            return false;\n        }\n        if (this == o) {\n            return true;\n        }\n        final CsvRowDataSerializationSchema that = (CsvRowDataSerializationSchema) o;\n        final CsvSchema otherSchema = that.csvSchema;\n\n        return rowType.equals(that.rowType)\n                && csvSchema.getColumnSeparator() == otherSchema.getColumnSeparator()\n                && Arrays.equals(csvSchema.getLineSeparator(), otherSchema.getLineSeparator())\n                && csvSchema","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvRowDataSerializationSchema.java#L165-L201","documentation":"Outer catch in CsvRowDataSerializationSchema.serialize(): any Throwable thrown while converting the RowData into the CSV ObjectNode or writing it with Jackson is re-thrown as RuntimeException(\"Could not serialize row '%s'.\"). The failing row is included and the real cause (usually a converter type error) is attached.","triggerScenarios":"RowData values incompatible with the declared CSV schema: wrong physical type in a GenericRowData, unsupported nested types, nulls rendered into positions the CsvSchema cannot format, or date/time strings that Jackson's CSV generator rejects.","commonSituations":"Custom sources emitting GenericRowData with mismatched internal representations (e.g. byte[] where STRING expected); schema drift between the producing job and the CSV sink DDL; timestamps with precision the CSV schema cannot render.","solutions":["Read the chained cause to identify which field/converter failed; the row dump shows the offending values.","Align the emitting side's RowType with the sink table schema exactly (types and nullability).","Test serialization in a unit test: new CsvRowDataSerializationSchema(rowType, options).serialize(row) to reproduce cheaply.","If the cause is an unsupported type, project/cast the column to a CSV-supported type (e.g. MAP to STRING) before the sink."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Reproduce serialization cheaply before deploying:\nSerializationSchema<RowData> ser = new CsvRowDataSerializationSchema(rowType, config);\nfor (RowData sample : representativeRows) { ser.serialize(sample); } // throws here, not in prod","typeGuard":null,"tryCatchPattern":"catch (RuntimeException e) { send the row (rendered in e.getMessage()) to a dead-letter sink; rethrow only for systemic causes (schema/registry) }","preventionTips":["Unit-test the serializer with nulls, extremes, and every RowKind","Keep emitting RowType identical to the sink DDL","Cast complex fields to STRING before CSV sinks"],"tags":["csv","serialization","wrapper-exception","row-data"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}