{"record":{"id":"6c2fbbebe278a18d","repo":"vitessio/vitess","slug":"status-func-registered-without-proper-prefix-need","errorCode":null,"errorMessage":"status func registered without proper prefix, need github_com_vitessio_vitess_:","messagePattern":"status func registered without proper prefix, need github_com_vitessio_vitess_:","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/servenv/status.go","lineNumber":196,"sourceCode":"\treturn sp\n}\n\nfunc (sp *statusPage) reset() {\n\tsp.mu.Lock()\n\tdefer sp.mu.Unlock()\n\n\tsp.sections = nil\n\tsp.tmpl = template.Must(sp.reparse(nil))\n\tsp.funcMap = make(template.FuncMap)\n}\n\nfunc (sp *statusPage) addStatusFuncs(fmap template.FuncMap) {\n\tsp.mu.Lock()\n\tdefer sp.mu.Unlock()\n\n\tfor name, fun := range fmap {\n\t\tif !strings.HasPrefix(name, \"github_com_vitessio_vitess_\") {\n\t\t\tpanic(\"status func registered without proper prefix, need github_com_vitessio_vitess_:\" + name)\n\t\t}\n\t\tif _, ok := sp.funcMap[name]; ok {\n\t\t\tpanic(\"duplicate status func registered: \" + name)\n\t\t}\n\t\tsp.funcMap[name] = fun\n\t}\n}\n\nfunc (sp *statusPage) addStatusPart(banner, fragment string, f func() any) {\n\tsp.mu.Lock()\n\tdefer sp.mu.Unlock()\n\n\tsecs := append(sp.sections, section{\n\t\tBanner:   banner,\n\t\tFragment: fragment,\n\t\tF:        f,\n\t})\n","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/servenv/status.go#L178-L214","documentation":"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.","triggerScenarios":"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}).","commonSituations":"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.","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"],"exampleFix":"// before\nservenv.AddStatusFuncs(template.FuncMap{\"myfunc\": myFunc})\n// after\nservenv.AddStatusFuncs(template.FuncMap{\"github_com_vitessio_vitess_myfunc\": myFunc})","handlingStrategy":"validation","validationCode":"const statusPrefix = \"github_com_vitessio_vitess_\"\nfor name := range fmap {\n\tif !strings.HasPrefix(name, statusPrefix) { return fmt.Errorf(\"missing prefix %s: %s\", statusPrefix, name) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build FuncMap keys via a helper that auto-prepends the prefix","Prefer AddStatusPart over AddStatusFuncs when possible","Lint registration calls for the required prefix"],"tags":["go","panic","servenv","status-page","naming"],"backgroundTag":"naming-convention-violation","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}