vitessio/vitess · error

duplicate status func registered:

Error message

duplicate status func registered: 

What it means

The status page keeps one template func map; registering a func under a name that is already present would overwrite an existing status function, so addStatusFuncs panics on the duplicate name (after the prefix check).

Source

Thrown at go/vt/servenv/status.go:199

func (sp *statusPage) reset() {
	sp.mu.Lock()
	defer sp.mu.Unlock()

	sp.sections = nil
	sp.tmpl = template.Must(sp.reparse(nil))
	sp.funcMap = make(template.FuncMap)
}

func (sp *statusPage) addStatusFuncs(fmap template.FuncMap) {
	sp.mu.Lock()
	defer sp.mu.Unlock()

	for name, fun := range fmap {
		if !strings.HasPrefix(name, "github_com_vitessio_vitess_") {
			panic("status func registered without proper prefix, need github_com_vitessio_vitess_:" + name)
		}
		if _, ok := sp.funcMap[name]; ok {
			panic("duplicate status func registered: " + name)
		}
		sp.funcMap[name] = fun
	}
}

func (sp *statusPage) addStatusPart(banner, fragment string, f func() any) {
	sp.mu.Lock()
	defer sp.mu.Unlock()

	secs := append(sp.sections, section{
		Banner:   banner,
		Fragment: fragment,
		F:        f,
	})

	var err error
	sp.tmpl, err = sp.reparse(secs)
	if err != nil {

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Rename your status func with a more specific suffix to make the name unique
  2. Remove the duplicate AddStatusFuncs call or make registration idempotent (register once)
  3. Check which packages call AddStatusFuncs in your binary and deduplicate names across them

Example fix

// before
AddStatusFuncs(tmpl.FuncMap{"github_com_vitessio_vitess_stats": f}) // twice
// after
AddStatusFuncs(tmpl.FuncMap{"github_com_vitessio_vitess_mystats": f})
Defensive patterns

Strategy: validation

Validate before calling

func uniqueNames(fmap template.FuncMap) error {
	seen := map[string]bool{}
	for name := range fmap { if seen[name] { return fmt.Errorf("duplicate %s", name) }; seen[name] = true }
	return nil
} // run before AddStatusFuncs

Prevention

When it happens

Trigger: Calling servenv.AddStatusFuncs twice with FuncMaps containing the same fully-prefixed name — e.g. two packages registering 'github_com_vitessio_vitess Durations'-style helpers under identical keys.

Common situations: Two vitess packages that both register a common helper name on the status page; importing a new package whose init() registers a name you already registered; tests registering the same func repeatedly.

Related errors


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