{"record":{"id":"484ca7e7778de783","repo":"vitessio/vitess","slug":"metadataread-unhandled-data-type-v","errorCode":null,"errorMessage":"metadataRead: unhandled data type: %v","messagePattern":"metadataRead: unhandled data type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/mysql/binlog_event_rbr.go","lineNumber":219,"sourceCode":"\t\t// One byte.\n\t\tdata[pos] = byte(value)\n\t\treturn pos + 1\n\n\tcase binlog.TypeNewDecimal, binlog.TypeEnum, binlog.TypeSet, binlog.TypeString:\n\t\t// Two bytes, Big Endian because of crazy encoding.\n\t\tdata[pos] = byte(value >> 8)\n\t\tdata[pos+1] = byte(value)\n\t\treturn pos + 2\n\n\tcase binlog.TypeVarchar, binlog.TypeBit, binlog.TypeVarString:\n\t\t// Two bytes, Little Endian\n\t\tdata[pos] = byte(value)\n\t\tdata[pos+1] = byte(value >> 8)\n\t\treturn pos + 2\n\n\tdefault:\n\t\t// Unknown type. This is used in tests only, so panic.\n\t\tpanic(vterrors.Errorf(vtrpcpb.Code_INTERNAL, \"metadataRead: unhandled data type: %v\", typ))\n\t}\n}\n\n// readColumnCollationIDs reads from the optional metadata that exists.\n// See: https://github.com/mysql/mysql-server/blob/8.0/libbinlogevents/include/rows_event.h\n// What's included depends on the server configuration:\n// https://dev.mysql.com/doc/refman/en/replication-options-binary-log.html#sysvar_binlog_row_metadata\n// and the table definition.\n// We only care about any collation IDs in the optional metadata and\n// this info is provided in all binlog_row_metadata formats. Note that\n// this info is only provided for text based columns.\nfunc readColumnCollationIDs(data []byte, pos, count int) ([]collations.ID, error) {\n\tcollationIDs := make([]collations.ID, 0, count)\n\tfor pos < len(data) {\n\t\tfieldType := uint8(data[pos])\n\t\tpos++\n\n\t\tfieldLen, read, ok := readLenEncInt(data, pos)","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/mysql/binlog_event_rbr.go#L201-L237","documentation":"metadataWrite serializes a column's optional metadata and panics with a vterrors INTERNAL error (note: the message text says \"metadataRead\" but it is raised from metadataWrite) when the column type is not in its supported switch. The default branch exists for tests with unknown types only.","triggerScenarios":"Calling NewTableMapEvent with a TableMap.Types entry whose metadata cannot be written because the type byte is not one of the handled binlog types.","commonSituations":"Synthetic test types; type codes from a newer MySQL version not yet supported; mismatches where metadataLength accepts a type but metadataWrite does not (or vice versa).","solutions":["Use a supported binlog.Type* constant for every column in TableMap.Types.","If the type is legitimate new MySQL metadata, add handling to metadataWrite, metadataRead, and metadataLength together.","Validate type codes before constructing the TableMap."],"exampleFix":"// before\ntm.Types = []byte{0xAB} // not handled by metadataWrite\n// after\ntm.Types = []byte{binlog.TypeVarchar}","handlingStrategy":"validation","validationCode":"for c, typ := range tm.Types {\n    if !isWritableMetadataType(typ) {\n        return errors.Errorf(\"type %d at column %d has no metadata writer\", typ, c)\n    }\n}","typeGuard":null,"tryCatchPattern":"func safeNewTableMap(f mysql.BinlogFormat, s *mysql.FakeBinlogStream, id uint64, tm *mysql.TableMap) (ev mysql.BinlogEvent, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"table map metadata write: %v\", r)\n        }\n    }()\n    return mysql.NewTableMapEvent(f, s, id, tm), nil\n}","preventionTips":["Only use column types supported by the metadata read/write pair.","Add new types to metadataLength, metadataWrite, and metadataRead simultaneously.","Sanitize binlog-sourced type codes before building TableMap structs."],"tags":["mysql","binlog","panics","internal"],"backgroundTag":"unhandled-column-type","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}