{"record":{"id":"9a1417e75e4a0874","repo":"vitessio/vitess","slug":"symbol-newauthenticator-must-be-of-type-func-au","errorCode":null,"errorMessage":"symbol NewAuthenticator must be of type `func() Authenticator`; have %T","messagePattern":"symbol NewAuthenticator must be of type `func\\(\\) Authenticator`; have %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtadmin/rbac/authentication.go","lineNumber":163,"sourceCode":"\tdefer authenticatorsM.Unlock()\n\n\tif f, ok := authenticators[path]; ok {\n\t\treturn f(), nil\n\t}\n\n\tp, err := plugin.Open(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tsym, err := p.Lookup(\"NewAuthenticator\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tf, ok := sym.(func() Authenticator)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"symbol NewAuthenticator must be of type `func() Authenticator`; have %T\", sym)\n\t}\n\n\tauthenticators[path] = f\n\treturn f(), nil\n}\n","sourceCodeStart":145,"sourceCodeEnd":169,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/rbac/authentication.go#L145-L169","documentation":"vtadmin loads RBAC authenticator implementations as Go plugins via the plugin package, expecting the plugin to export a symbol `NewAuthenticator` with the exact type `func() Authenticator`. If the symbol exists but has a different signature (including non-zero parameters or different return types), the plugin load fails with this type assertion error. This is how vtadmin enforces the authenticator constructor contract at plugin load time.","triggerScenarios":"Building a custom authenticator plugin whose NewAuthenticator has parameters (e.g., func(cfg map[string]string) Authenticator), returns a concrete type rather than the Authenticator interface, or returns (Authenticator, error).","commonSituations":"Writing a new plugin after copying an example with a different constructor signature; compiling against a different version of the vtadmin rbac package so the Authenticator interface type differs between plugin and host; exporting the wrong symbol type entirely.","solutions":["Change the plugin to export `func NewAuthenticator() rbac.Authenticator` exactly — no parameters, single interface return.","Configure constructor arguments through plugin state or environment instead of constructor parameters.","Rebuild the plugin against the exact same version/commit of the vtadmin rbac package the host binary uses so interface types are identical.","Verify with `nm` or `go plugin` inspection that NewAuthenticator is exported and its symbol type matches."],"exampleFix":"// before\nfunc NewAuthenticator(cfg map[string]string) *MyAuth { ... }\n// after\nfunc NewAuthenticator() rbac.Authenticator {\n\tcfg := loadConfigFromEnv()\n\treturn &MyAuth{cfg: cfg}\n}","handlingStrategy":"type-guard","validationCode":"p, err := plugin.Open(path)\nif err != nil { return err }\nsym, err := p.Lookup(\"NewAuthenticator\")\nif err != nil { return err }\nif _, ok := sym.(func() rbac.Authenticator); !ok {\n\treturn fmt.Errorf(\"plugin %s: NewAuthenticator has wrong signature\", path)\n}","typeGuard":"func isValidAuthenticatorPlugin(sym plugin.Symbol) bool {\n\t_, ok := sym.(func() Authenticator)\n\treturn ok\n}","tryCatchPattern":"auth, err := rbac.NewAuthenticatorFromPath(path)\nif err != nil && strings.Contains(err.Error(), \"must be of type\") {\n\treturn fmt.Errorf(\"plugin %s incompatible: rebuild against host vtadmin version\", path)\n}","preventionTips":["Copy the canonical plugin template so NewAuthenticator has signature func() Authenticator.","Build plugins with the exact same Go version and vtadmin module version as the host binary.","Smoke-test plugin loading in CI before deploying.","Pass configuration via env or plugin state, never constructor parameters."],"tags":["plugin","rbac","authentication","vtadmin","go-plugin"],"backgroundTag":"plugin-symbol-type-mismatch","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}