{"record":{"id":"626152ffee27873d","repo":"apache/flink","slug":"unsupported-operation-s-for-row-kind-626152","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/maxwell/MaxwellJsonSerializationSchema.java","lineNumber":94,"sourceCode":"    }\n\n    @Override\n    public byte[] serialize(RowData element) {\n        reuse.setField(0, element);\n        reuse.setField(1, rowKind2String(element.getRowKind()));\n        return jsonSerializer.serialize(reuse);\n    }\n\n    private StringData rowKind2String(RowKind rowKind) {\n        switch (rowKind) {\n            case INSERT:\n            case UPDATE_AFTER:\n                return OP_INSERT;\n            case UPDATE_BEFORE:\n            case DELETE:\n                return OP_DELETE;\n            default:\n                throw new UnsupportedOperationException(\n                        \"Unsupported operation '\" + rowKind + \"' for row kind.\");\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        MaxwellJsonSerializationSchema that = (MaxwellJsonSerializationSchema) o;\n        return Objects.equals(jsonSerializer, that.jsonSerializer)\n                && timestampFormat == that.timestampFormat;\n    }\n\n    @Override","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/maxwell/MaxwellJsonSerializationSchema.java#L76-L112","documentation":"MaxwellJsonSerializationSchema.rowKind2String maps only INSERT/UPDATE_AFTER to 'insert' and UPDATE_BEFORE/DELETE to 'delete'. Any other RowKind reaches the default branch and throws UnsupportedOperationException — in practice unreachable with the standard four CDC kinds, but hit if a custom operator emits an extended RowKind.","triggerScenarios":"A custom source/function upstream of a maxwell-json sink sets a RowKind outside the four standard values; test code constructs RowData with RowKind.valueOf on an unknown identifier.","commonSituations":"Reusing RowKind short codes for custom markers; evolving Flink versions adding RowKind values not covered by the format; unit tests feeding arbitrary kinds.","solutions":["Clamp non-CDC RowKinds to INSERT (or UPDATE_AFTER) in a map before the sink.","Audit custom operators for RowKind.fromShortValue/valueOf usage and restrict to the four CDC kinds."],"exampleFix":"// before\nrow.setRowKind(RowKind.fromShortValue((short) 9));\n// after\nrow.setRowKind(RowKind.INSERT);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static String maxwellOpOf(RowKind k) {\n    switch (k) {\n        case INSERT:\n        case UPDATE_AFTER: return \"insert\";\n        case UPDATE_BEFORE:\n        case DELETE: return \"delete\";\n        default: return null; // caller clamps or rejects before serialization\n    }\n}","tryCatchPattern":null,"preventionTips":["Clamp RowKind to the four CDC values in the last map before the sink.","Cover all four kinds in unit tests of custom producers."],"tags":["flink","maxwell","json","serialization","rowkind"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}