{"record":{"id":"f9bd080032b999f7","repo":"vitessio/vitess","slug":"err","errorCode":null,"errorMessage":"err","messagePattern":"err","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/mysql/replication/gtid.go","lineNumber":110,"sourceCode":"// a GTID interface value with the correct underlying flavor.\nfunc DecodeGTID(s string) (GTID, error) {\n\tif s == \"\" {\n\t\treturn nil, nil\n\t}\n\n\tparts := strings.SplitN(s, \"/\", 2)\n\tif len(parts) != 2 {\n\t\t// There is no flavor. Try looking for a default parser.\n\t\treturn ParseGTID(\"\", s)\n\t}\n\treturn ParseGTID(parts[0], parts[1])\n}\n\n// MustDecodeGTID calls DecodeGTID and panics on error.\nfunc MustDecodeGTID(s string) GTID {\n\tgtid, err := DecodeGTID(s)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn gtid\n}\n","sourceCodeStart":92,"sourceCodeEnd":114,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/mysql/replication/gtid.go#L92-L114","documentation":"MustDecodeGTID is the panicking variant of DecodeGTID, which parses an encoded GTID string of the form \"flavor:value\". On any decode failure (missing separator, unknown flavor, bad value) it panics. Use only when the string is known to have been produced by EncodeGTID.","triggerScenarios":"Calling MustDecodeGTID(s) with a string that lacks the \"flavor:value\" form, contains an unknown flavor prefix, or holds a value invalid for that flavor.","commonSituations":"Reading GTIDs stored in external stores (etcd, user configs) that were written by older Vitess versions or other tools with a different encoding; hand-edited strings.","solutions":["Use DecodeGTID with error handling for any externally stored or user-supplied string","Ensure the string was produced by EncodeGTID (flavor included) rather than a bare value","Validate format (split on first ':' and check flavor) before the Must* call"],"exampleFix":"// before\ngtid := replication.MustDecodeGTID(raw)\n// after\ngtid, err := replication.DecodeGTID(raw)\nif err != nil {\n\treturn vterrors.Wrapf(err, \"cannot decode GTID %q\", raw)\n}","handlingStrategy":"try-catch","validationCode":"if !strings.Contains(s, \":\") {\n\treturn fmt.Errorf(\"encoded GTID %q missing flavor separator\", s)\n}","typeGuard":null,"tryCatchPattern":"func safeDecodeGTID(s string) (gtid replication.GTID, err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"MustDecodeGTID panicked on %q: %v\", s, r)\n\t\t}\n\t}()\n\treturn replication.MustDecodeGTID(s), nil\n}","preventionTips":["Only pass strings produced by EncodeGTID to Must*","Use DecodeGTID for anything from external storage or users","Round-trip test stored GTID strings after version upgrades"],"tags":["panic","gtid","parsing"],"backgroundTag":"invalid-gtid-format","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}