vitessio/vitess · error
status func registered without proper prefix, need github_co
Error message
status func registered without proper prefix, need github_com_vitessio_vitess_:
What it means
Status template funcs on the vitess status page must be namespaced with the prefix 'github_com_vitessio_vitess_' to avoid collisions in the shared template func map. addStatusFuncs panics for any function name lacking that prefix.
Source
Thrown at go/vt/servenv/status.go:196
return sp
}
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,
})
View on GitHub (pinned to 01a25a7d17)
Solutions
- Prefix every func name with 'github_com_vitessio_vitess_', e.g. 'github_com_vitessio_vitess_myfunc'
- Use the higher-level AddStatusPart helper if you do not need shared template funcs
- Fix the FuncMap keys before registering
Example fix
// before
servenv.AddStatusFuncs(template.FuncMap{"myfunc": myFunc})
// after
servenv.AddStatusFuncs(template.FuncMap{"github_com_vitessio_vitess_myfunc": myFunc}) Defensive patterns
Strategy: validation
Validate before calling
const statusPrefix = "github_com_vitessio_vitess_"
for name := range fmap {
if !strings.HasPrefix(name, statusPrefix) { return fmt.Errorf("missing prefix %s: %s", statusPrefix, name) }
} Prevention
- Build FuncMap keys via a helper that auto-prepends the prefix
- Prefer AddStatusPart over AddStatusFuncs when possible
- Lint registration calls for the required prefix
When it happens
Trigger: Calling servenv.AddStatusFuncs (which reaches addStatusFuncs via the status page) with a template.FuncMap whose keys do not start with 'github_com_vitessio_vitess_', e.g. AddStatusFuncs(template.FuncMap{"myfunc": f}).
Common situations: Developers adding status endpoints/helpers forgetting the required long prefix; tests like TestNamedStatus exercising the guard; ported code from other Go services using plain function names.
Related errors
- duplicate status func registered:
- failed to load static auth plugin. Plugin configured but grp
- missing value for 'rate'
- missing value for 'path'
- panic: %v
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/6c2fbbebe278a18d.
Report an issue: GitHub.