{"record":{"id":"45261926df0af94e","repo":"vitessio/vitess","slug":"errimplementationnotregistered","errorCode":"ErrImplementationNotRegistered","errorMessage":"%w %s","messagePattern":"%w %s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtadmin/cluster/discovery/discovery.go","lineNumber":121,"sourceCode":"\n\t_, ok := registry[name]\n\tif ok {\n\t\tpanic(\"[discovery] factory already registered for \" + name)\n\t}\n\n\tregistry[name] = factory\n}\n\n// New returns a Discovery implementation using the registered factory for the\n// implementation. Usage of the args slice is dependent on the implementation's\n// factory.\nfunc New(impl string, cluster *vtadminpb.Cluster, args []string) (Discovery, error) {\n\tregistryMu.Lock()\n\tfactory, ok := registry[impl]\n\tregistryMu.Unlock()\n\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"%w %s\", ErrImplementationNotRegistered, impl)\n\t}\n\n\treturn factory(cluster, pflag.NewFlagSet(\"discovery:\"+impl, pflag.ContinueOnError), args)\n}\n\nfunc init() {\n\tRegister(\"consul\", NewConsul)\n\tRegister(\"staticfile\", NewStaticFile)\n\tRegister(\"dynamic\", NewDynamic)\n}\n","sourceCodeStart":103,"sourceCodeEnd":132,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/cluster/discovery/discovery.go#L103-L132","documentation":"Discovery.New looks up the requested discovery implementation (e.g. \"consul\", \"etcd\", \"vitesstopology\") in a package-level registry populated by init() functions. If the impl string is not registered, the constructor fails with ErrImplementationNotRegistered wrapped together with the impl name. This guards against building a cluster whose discovery backend does not exist or was never linked in.","triggerScenarios":"Calling discovery.New(\"myimpl\", cluster, args) with an impl name that no registered factory provides; can also occur when the package containing the implementation's init() is not imported into the binary, so its factory never registers.","commonSituations":"Typo in the discovery impl flag (e.g. \"consul\" misspelled), building a custom binary that forgot to import the implementation package (blank import _ \"...discovery/implconsul\"), or renaming an implementation without updating deployment configs.","solutions":["Correct the impl string to a registered implementation name (check registry keys / available impl packages).","Add a blank import of the implementation package in your binary so its init() registers the factory (e.g. _ \"vitess.io/vitess/go/vt/vtadmin/cluster/discovery/implconsul\").","Compare your flag/env value against the impl names registered in the discovery package before calling New."],"exampleFix":"// before\nimport \"vitess.io/vitess/go/vt/vtadmin/cluster/discovery\"\nd, err := discovery.New(\"consul\", cluster, args) // impl package never imported\n// after\nimport (\n    _ \"vitess.io/vitess/go/vt/vtadmin/cluster/discovery/implconsul\"\n    \"vitess.io/vitess/go/vt/vtadmin/cluster/discovery\"\n)\nd, err := discovery.New(\"consul\", cluster, args)","handlingStrategy":"validation","validationCode":"// ensure the impl package is linked and the name is registered before New\nswitch impl {\ncase \"consul\", \"etcd2\":\n    // known registered implementations\ndefault:\n    return fmt.Errorf(\"unsupported discovery impl %q\", impl)\n}","typeGuard":null,"tryCatchPattern":"d, err := discovery.New(impl, cluster, args)\nif err != nil {\n    if errors.Is(err, discovery.ErrImplementationNotRegistered) {\n        log.Fatalf(\"discovery impl %q not registered; check imports/config\", impl)\n    }\n    return err\n}","preventionTips":["Add blank imports (_ \".../discovery/implconsul\") for every implementation your binary supports.","Keep the impl string in one shared constant used by both registration and lookup.","Compare configured impl values against the registry keys in a startup smoke test."],"tags":["go","registry","discovery","misconfiguration"],"backgroundTag":"implementation-not-registered","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}