{"record":{"id":"63eaeaae9070f149","repo":"apache/flink","slug":"unsupported-operation-s-for-row-kind-63eaea","errorCode":null,"errorMessage":"Unsupported operation '%s' for row kind.","messagePattern":"Unsupported operation '(.+?)' for row kind\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/debezium/DebeziumJsonSerializationSchema.java","lineNumber":94,"sourceCode":"\n    @Override\n    public byte[] serialize(RowData rowData) {\n        try {\n            switch (rowData.getRowKind()) {\n                case INSERT:\n                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;","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/debezium/DebeziumJsonSerializationSchema.java#L76-L112","documentation":"Thrown by DebeziumJsonSerializationSchema.serialize when the incoming RowData has a RowKind not in {INSERT, UPDATE_AFTER, UPDATE_BEFORE, DELETE}. The serializer maps INSERT/UPDATE_AFTER to the 'r'/'c' ops and UPDATE_BEFORE/DELETE to the 'd' op; any other RowKind hits the default branch with UnsupportedOperationException, which is then wrapped into RuntimeException('Could not serialize row ...').","triggerScenarios":"Serializing a RowData whose RowKind is a custom/extended kind beyond the four CDC kinds — practically only reachable via a custom pipeline that sets RowKind via valueOf on an unknown short value, or a downstream operator emitting a non-standard kind into a debezium-json sink.","commonSituations":"Custom sources or ProcessFunctions reusing RowKind short codes outside 0..3; version changes introducing new RowKind enum values; test harnesses constructing GenericRowData with arbitrary RowKind.","solutions":["Ensure upstream operators only emit RowKind.INSERT, UPDATE_BEFORE, UPDATE_AFTER, or DELETE into a debezium-json sink.","Normalize RowKinds in a preceding map: convert non-CDC kinds (e.g. clamp everything else to INSERT) before the sink.","If the exception surfaces as 'Could not serialize row', inspect the cause — this UnsupportedOperationException indicates the row kind, not the payload, is the problem."],"exampleFix":"// before\ngenericRow.setRowKind(RowKind.fromShortValue((short) 7)); // unknown kind\nout.collect(genericRow);\n// after\ngenericRow.setRowKind(RowKind.INSERT);\nout.collect(genericRow);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"private static final Set<RowKind> CDC_KINDS = EnumSet.of(\n        RowKind.INSERT, RowKind.UPDATE_BEFORE, RowKind.UPDATE_AFTER, RowKind.DELETE);\n\nstatic boolean isCdcRowKind(RowData row) {\n    return CDC_KINDS.contains(row.getRowKind());\n}","tryCatchPattern":"Catch RuntimeException around serialization, inspect getCause() instanceof UnsupportedOperationException and its message for 'row kind' before deciding to skip or fail.","preventionTips":["Validate RowKind in a map before the debezium-json sink.","Never construct RowKinds via fromShortValue with unchecked external input."],"tags":["flink","debezium","json","serialization","rowkind"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}