{"record":{"id":"88bc695116c55243","repo":"vitessio/vitess","slug":"parsebinlogcoordinates-cannot-parse-binlogcoordin","errorCode":null,"errorMessage":"ParseBinlogCoordinates: Cannot parse BinlogCoordinates from %s. Expected format is file:pos","messagePattern":"ParseBinlogCoordinates: Cannot parse BinlogCoordinates from (.+?)\\. Expected format is file:pos","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtorc/inst/binlog.go","lineNumber":52,"sourceCode":"\nconst (\n\tBinaryLog BinlogType = iota\n\tRelayLog\n)\n\n// BinlogCoordinates described binary log coordinates in the form of log file & log position.\ntype BinlogCoordinates struct {\n\tLogFile string\n\tLogPos  uint64\n\tType    BinlogType\n}\n\n// ParseBinlogCoordinates will parse a string representation such as \"mysql-bin.000001:12345\"\n// into a BinlogCoordinates struct.\nfunc ParseBinlogCoordinates(logFileLogPos string) (*BinlogCoordinates, error) {\n\ttokens := strings.SplitN(logFileLogPos, \":\", 2)\n\tif len(tokens) != 2 {\n\t\treturn nil, fmt.Errorf(\"ParseBinlogCoordinates: Cannot parse BinlogCoordinates from %s. Expected format is file:pos\", logFileLogPos)\n\t}\n\n\tlogPos, err := strconv.ParseUint(tokens[1], 10, 64)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ParseBinlogCoordinates: invalid pos: %s\", tokens[1])\n\t}\n\treturn &BinlogCoordinates{LogFile: tokens[0], LogPos: logPos}, nil\n}\n\n// DisplayString returns a user-friendly string representation of these coordinates\nfunc (binlogCoordinates *BinlogCoordinates) DisplayString() string {\n\treturn fmt.Sprintf(\"%s:%d\", binlogCoordinates.LogFile, binlogCoordinates.LogPos)\n}\n\n// String returns a user-friendly string representation of these coordinates\nfunc (binlogCoordinates BinlogCoordinates) String() string {\n\treturn binlogCoordinates.DisplayString()\n}","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtorc/inst/binlog.go#L34-L70","documentation":"vtorc's inst.ParseBinlogCoordinates expects a string of the form 'file:pos' (e.g. 'mysql-bin.000001:12345'). If the input has no colon-delimited second token, parsing fails with this error. It is used to convert replication position strings into BinlogCoordinates structs.","triggerScenarios":"Calling ParseBinlogCoordinates (via getBinlogCoordinatesFromPositionString) with a string lacking a colon, e.g. an empty string, a bare binlog file name 'mysql-bin.000001', or a GTID set instead of file:pos coordinates.","commonSituations":"Feeding SHOW MASTER STATUS output columns in the wrong order, passing an empty ExecMasterPosition from a server that never replicated, or mixing GTID-based positions into file:pos-based code paths.","solutions":["Ensure the input is exactly 'binlog-file:position' with a non-empty file name and integer position","Check where the string originates (ShowMasterStatus/ShowSlaveStatus field mapping) and fix column ordering","Handle empty positions before calling: return early if the source string is blank","If the topology uses GTID replication, use the GTID-aware position APIs instead of binlog coordinates"],"exampleFix":"// before\ncoords, err := inst.ParseBinlogCoordinates(\"mysql-bin.000001\")\n// after\ncoords, err := inst.ParseBinlogCoordinates(\"mysql-bin.000001:4711\")","handlingStrategy":"validation","validationCode":"func validBinlogCoords(s string) bool {\n    parts := strings.SplitN(s, \":\", 2)\n    if len(parts) != 2 || parts[0] == \"\" || parts[1] == \"\" {\n        return false\n    }\n    _, err := strconv.ParseUint(parts[1], 10, 64)\n    return err == nil\n}","typeGuard":null,"tryCatchPattern":"if !validBinlogCoords(raw) {\n    return fmt.Errorf(\"skipping invalid coordinates %q\", raw)\n}\ncoords, err := inst.ParseBinlogCoordinates(raw)\nif err != nil { return err }","preventionTips":["Always format positions as file:pos with strconv before passing in","Never pass GTID sets or bare file names into ParseBinlogCoordinates","Trim and normalize strings scraped from shell output before parsing","Unit-test coordinate parsing with real SHOW status output formats"],"tags":["vtorc","parsing","replication","binlog"],"backgroundTag":"binlog-coordinate-parse-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}