vitessio/vitess · error

err

Error message

err

What it means

MustParsePosition calls ParsePosition(flavor, value) and panics on error. It parses a replication position string (GTID set) for a given flavor; invalid flavor or malformed GTID set strings crash instead of returning an error. Intended for tests and known-valid constants.

Source

Thrown at go/mysql/replication/replication_position.go:155

// after the given GTIDSet is replicated.
func AppendGTIDSetInPlace(rp Position, gtidSet GTIDSet) Position {
	if gtidSet == nil {
		return rp
	}

	if rp.GTIDSet == nil {
		return AppendGTIDSet(rp, gtidSet)
	}
	rp.GTIDSet = rp.GTIDSet.UnionInPlace(gtidSet)
	return rp
}

// MustParsePosition calls ParsePosition and panics
// on error.
func MustParsePosition(flavor, value string) Position {
	rp, err := ParsePosition(flavor, value)
	if err != nil {
		panic(err)
	}
	return rp
}

// EncodePosition returns a string that contains both the flavor
// and value of the Position, so that the correct parser can be
// selected when that string is passed to DecodePosition.
func EncodePosition(rp Position) string {
	if rp.GTIDSet == nil {
		return ""
	}
	return fmt.Sprintf("%s/%s", rp.GTIDSet.Flavor(), rp.GTIDSet.String())
}

// DecodePosition converts a string in the format returned by
// EncodePosition back into a Position value with the
// correct underlying flavor.
func DecodePosition(s string) (rp Position, err error) {

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Use ParsePosition and handle the error for any runtime input
  2. Validate the position string format for the expected flavor before calling
  3. Confirm the flavor argument matches the source server type

Example fix

// before
pos := replication.MustParsePosition("MySQL56", flagPos)
// after
pos, err := replication.ParsePosition("MySQL56", flagPos)
if err != nil {
	return vterrors.Wrapf(err, "invalid position %q", flagPos)
}
Defensive patterns

Strategy: validation

Validate before calling

if _, err := replication.ParsePosition(flavor, value); err != nil {
	return vterrors.Wrapf(err, "invalid position %q", value)
}

Try / catch

func safeParsePosition(flavor, value string) (pos replication.Position, err error) {
	defer func() {
		if r := recover(); r != nil {
			err = fmt.Errorf("MustParsePosition panicked: %v", r)
		}
	}()
	return replication.MustParsePosition(flavor, value), nil
}

Prevention

When it happens

Trigger: Calling MustParsePosition with an unsupported flavor (anything but MySQL56/MariaDB) or a malformed position value such as "invalid-gtid-set" or a GTID set from the wrong flavor syntax.

Common situations: Loading positions from config/flags/topology where the string was hand-written, truncated, or produced by a different MySQL flavor.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/8676fe5a107ee602. Report an issue: GitHub.