{"record":{"id":"3cbbc3057be64bbe","repo":"apache/seatunnel","slug":"fail-to-serialize-at-field-fieldname","errorCode":null,"errorMessage":"Fail to serialize at field: ${fieldName}.","messagePattern":"Fail to serialize at field: (.+?)\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-hudi/src/main/java/org/apache/seatunnel/connectors/seatunnel/hudi/sink/convert/RowDataToAvroConverters.java","lineNumber":257,"sourceCode":"                        .toArray(RowDataToAvroConverter[]::new);\n        final SeaTunnelDataType<?>[] fieldTypes = rowType.getFieldTypes();\n\n        return new RowDataToAvroConverter() {\n            private static final long serialVersionUID = 1L;\n\n            @Override\n            public Object convert(Schema schema, Object object) {\n                final SeaTunnelRow row = (SeaTunnelRow) object;\n                final List<Schema.Field> fields = schema.getFields();\n                final GenericRecord record = new GenericData.Record(schema);\n                for (int i = 0; i < fieldTypes.length; ++i) {\n                    final Schema.Field schemaField = fields.get(i);\n                    try {\n                        Object avroObject =\n                                fieldConverters[i].convert(schemaField.schema(), row.getField(i));\n                        record.put(i, avroObject);\n                    } catch (Throwable t) {\n                        throw new RuntimeException(\n                                String.format(\n                                        \"Fail to serialize at field: %s.\", schemaField.name()),\n                                t);\n                    }\n                }\n                return record;\n            }\n        };\n    }\n\n    private static RowDataToAvroConverter createArrayConverter(ArrayType<?, ?> arrayType) {\n        final RowDataToAvroConverter elementConverter = createConverter(arrayType.getElementType());\n\n        return new RowDataToAvroConverter() {\n            private static final long serialVersionUID = 1L;\n\n            @Override\n            public Object convert(Schema schema, Object object) {","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-hudi/src/main/java/org/apache/seatunnel/connectors/seatunnel/hudi/sink/convert/RowDataToAvroConverters.java#L239-L275","documentation":"The row converter wraps per-field Avro conversion in a try/catch and rethrows as a RuntimeException annotated with the failing field name, so users know which schema field caused serialization to fail; the original cause is chained.","triggerScenarios":"During convert() of a SeaTunnelRow to an Avro record, fieldConverters[i].convert() throws for field i (value not matching the Avro schema, e.g. wrong type, out-of-domain value, null in non-nullable field).","commonSituations":"Source row value types diverging from declared SeaTunnel schema; Hudi Avro schema evolved while data uses old types; character/date conversion failures on malformed values.","solutions":["Inspect the chained cause ('Caused by') to find the root type/encoding problem and fix the data or schema","Align the SeaTunnel source schema with the Hudi table Avro schema (types must match field-by-field)","Cast offending columns upstream with a SQL transform to the expected type","Refresh stale Hudi table schema configuration after schema evolution"],"exampleFix":"// before: field 'age' declared STRING in source, INT in Avro schema\n// after: CAST(age AS INT) in upstream SQL transform","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    sink.write(row);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Fail to serialize at field:\")) {\n        String field = e.getMessage().replace(\"Fail to serialize at field: \", \"\").replace(\".\", \"\");\n        LOG.error(\"Check value/type of field {} against the Hudi Avro schema; cause: {}\", field, e.getCause());\n    } else { throw e; }\n}","preventionTips":["Keep source schema and Hudi Avro schema in sync field-by-field","Use SQL CAST transforms to normalize types before the sink","Check 'Caused by' first when debugging — the wrapper only names the field"],"tags":["hudi","avro","serialization","field"],"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-14T11:17:12.474Z"}