{"record":{"id":"a7c56e10dfbf536d","repo":"apache/flink","slug":"could-not-serialize-row-s-a7c56e","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/ogg/OggJsonSerializationSchema.java","lineNumber":112,"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        OggJsonSerializationSchema that = (OggJsonSerializationSchema) o;\n        return Objects.equals(jsonSerializer, that.jsonSerializer);\n    }\n\n    @Override\n    public int hashCode() {\n        return Objects.hash(jsonSerializer);","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/ogg/OggJsonSerializationSchema.java#L94-L130","documentation":"The catch-all in OggJsonSerializationSchema.serialize wraps every Throwable from building the [before, after, op_type] envelope and calling the internal JSON serializer into RuntimeException('Could not serialize row ...'). The meaningful failure is the attached cause: unsupported RowKind, null in a non-nullable field, or a field value the generated serializer cannot convert to JSON.","triggerScenarios":"Any exception inside serialize(): default-branch RowKind error; schema mismatch between the RowData produced upstream and the physical RowType the schema was built for; nulls where primitives are expected.","commonSituations":"Sink DDL drifted from the producing schema (field order/count/type changes) while the serialization schema was not rebuilt; custom RowData implementations returning null fields.","solutions":["Inspect the cause chain (t) — fix the underlying RowKind/type/null problem it names.","Rebuild the serialization schema (restart/re-create the sink) after any DDL change so codegen matches.","Add a narrow map upstream validating arity and nullability against the sink schema before rows hit the sink."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (row.getArity() != sinkArity) throw new IllegalArgumentException(\"arity mismatch vs ogg-json sink\");","typeGuard":null,"tryCatchPattern":"try { schema.serialize(row); } catch (RuntimeException e) { log.error(\"ogg serialize failed, cause {}\", e.getCause()); deadLetter.write(row, e.getCause()); }","preventionTips":["Always inspect the cause, not the wrapper text.","Recreate the serialization schema after DDL changes to keep codegen in sync."],"tags":["flink","ogg","json","serialization","wrapper-exception"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}