{"record":{"id":"16965bfd2d9a0944","repo":"vitessio/vitess","slug":"parsebinlogcoordinates-invalid-pos-s","errorCode":null,"errorMessage":"ParseBinlogCoordinates: invalid pos: %s","messagePattern":"ParseBinlogCoordinates: invalid pos: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtorc/inst/binlog.go","lineNumber":57,"sourceCode":"\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}\n\n// Equals tests equality of this coordinate and another one.\nfunc (binlogCoordinates *BinlogCoordinates) Equals(other *BinlogCoordinates) bool {\n\tif other == nil {\n\t\treturn false","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtorc/inst/binlog.go#L39-L75","documentation":"The position part of a 'file:pos' string could not be parsed as an unsigned 64-bit integer by strconv.ParseUint. The file name portion was fine, but the text after the first colon is not a valid decimal integer (or is empty).","triggerScenarios":"ParseBinlogCoordinates receiving inputs like 'mysql-bin.000001:abc', 'mysql-bin.000001:', or a position containing whitespace/newline from shell output or a mis-split log line.","commonSituations":"Scraping replication status from shell scripts that leave trailing whitespace or CR (Windows line endings), copying coordinates with extra characters, or a log file name containing a colon followed by non-numeric text.","solutions":["Trim whitespace (strings.TrimSpace) from the coordinates string before parsing","Verify the position field is a plain decimal integer: 'mysql-bin.000001:4711'","Check the source of the string for CRLF line endings or appended units","Confirm you split on the LAST colon if the binlog file path itself contains colons"],"exampleFix":"// before\ncoords, err := inst.ParseBinlogCoordinates(\"mysql-bin.000001: 4711\\n\")\n// after\ncoords, err := inst.ParseBinlogCoordinates(strings.TrimSpace(\"mysql-bin.000001:4711\"))","handlingStrategy":"validation","validationCode":"func validBinlogPos(s string) bool {\n    parts := strings.SplitN(s, \":\", 2)\n    if len(parts) != 2 {\n        return false\n    }\n    _, err := strconv.ParseUint(strings.TrimSpace(parts[1]), 10, 64)\n    return err == nil\n}","typeGuard":null,"tryCatchPattern":"raw = strings.TrimSpace(raw)\nif !validBinlogPos(raw) {\n    return fmt.Errorf(\"invalid position in %q\", raw)\n}\ncoords, err := inst.ParseBinlogCoordinates(raw)","preventionTips":["strings.TrimSpace any value sourced from logs or shell output","Strip CR characters from Windows-generated files","Validate positions with ParseUint before calling library parsers","Use structured SHOW status parsing instead of text scraping where possible"],"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"}