{"record":{"id":"8fa6c352c1b542be","repo":"vitessio/vitess","slug":"not-implemented-post-header-length-8","errorCode":null,"errorMessage":"Not implemented, post_header_length!=8","messagePattern":"Not implemented, post_header_length!=8","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/mysql/binlog_event_make.go","lineNumber":333,"sourceCode":"\tdata[10] = byte(gtid.Domain >> 16)\n\tdata[11] = byte(gtid.Domain >> 24)\n\n\tconst FLStandalone = 1\n\tvar flags2 byte\n\tif !hasBegin {\n\t\tflags2 |= FLStandalone\n\t}\n\tdata[12] = flags2\n\n\tev := s.Packetize(f, eMariaGTIDEvent, 0, data)\n\treturn NewMariadbBinlogEvent(ev)\n}\n\n// NewTableMapEvent returns a TableMap event.\n// Only works with post_header_length=8.\nfunc NewTableMapEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, tm *TableMap) BinlogEvent {\n\tif f.HeaderSize(eTableMapEvent) != 8 {\n\t\tpanic(\"Not implemented, post_header_length!=8\")\n\t}\n\n\tmetadataLength := metadataTotalLength(tm.Types)\n\n\tlength := 6 + // table_id\n\t\t2 + // flags\n\t\t1 + // schema name length\n\t\tlen(tm.Database) +\n\t\t1 + // [00]\n\t\t1 + // table name length\n\t\tlen(tm.Name) +\n\t\t1 + // [00]\n\t\tlenEncIntSize(uint64(len(tm.Types))) + // column-count len enc\n\t\tlen(tm.Types) +\n\t\tlenEncIntSize(uint64(metadataLength)) + // lenenc-str column-meta-def\n\t\tmetadataLength +\n\t\tlen(tm.CanBeNull.data)\n\tdata := make([]byte, length)","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/mysql/binlog_event_make.go#L315-L351","documentation":"NewTableMapEvent can only synthesize a table-map binlog event when the binlog format's post-header length for table-map events is 8 bytes. If the format declares a different header size, the builder panics because the encoding logic only supports the 8-byte layout.","triggerScenarios":"Calling mysql.NewTableMapEvent with a BinlogFormat whose HeaderSize(eTableMapEvent) is not 8 (e.g. a fake format built with a 6-byte post-header length).","commonSituations":"Unit tests or tools constructing binlog events with hand-crafted BinlogFormat values copied from a different event type or an older MySQL/MariaDB flavor; misconfigured fake streams in test harnesses.","solutions":["Configure the BinlogFormat so the table-map event header size is 8 (as produced by MySQL 5.1+/MariaDB with row-based replication).","Parse the format from a real Format Description event instead of hard-coding header sizes.","If you must support other header sizes, extend NewTableMapEvent rather than reusing it."],"exampleFix":"// before\nf.HeaderSize[eTableMapEvent] = 6\nev := mysql.NewTableMapEvent(f, s, tableID, tm) // panics\n// after\nf.HeaderSize[eTableMapEvent] = 8\nev := mysql.NewTableMapEvent(f, s, tableID, tm)","handlingStrategy":"validation","validationCode":"if f.HeaderSize(mysql.ETableMapEvent) != 8 {\n    return errors.New(\"table-map post_header_length must be 8\")\n}\nev := mysql.NewTableMapEvent(f, s, tableID, tm)","typeGuard":null,"tryCatchPattern":"func makeTableMap(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(\"NewTableMapEvent: %v\", r)\n        }\n    }()\n    return mysql.NewTableMapEvent(f, s, id, tm), nil\n}","preventionTips":["Derive BinlogFormat from a real Format Description event instead of hand-crafting it.","Assert header sizes in test setup before building events.","Keep the table-map header size consistent with the server flavor you emulate (8 for modern RBR)."],"tags":["mysql","binlog","panics","unsupported"],"backgroundTag":"unsupported-binlog-format","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}