{"record":{"id":"b1e3cbeea38cfec0","repo":"hashicorp/nomad","slug":"plugin-name-must-not-be-empty","errorCode":null,"errorMessage":"Plugin.Name must not be empty","messagePattern":"Plugin\\.Name must not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/dynamicplugins/registry.go","lineNumber":186,"sourceCode":"}\n\nfunc (d *dynamicRegistry) RegisterPlugin(info *PluginInfo) error {\n\tif info.Type == \"\" {\n\t\t// This error shouldn't make it to a production cluster and is to aid\n\t\t// developers during the development of new plugin types.\n\t\treturn errors.New(\"Plugin.Type must not be empty\")\n\t}\n\n\tif info.ConnectionInfo == nil {\n\t\t// This error shouldn't make it to a production cluster and is to aid\n\t\t// developers during the development of new plugin types.\n\t\treturn errors.New(\"Plugin.ConnectionInfo must not be nil\")\n\t}\n\n\tif info.Name == \"\" {\n\t\t// This error shouldn't make it to a production cluster and is to aid\n\t\t// developers during the development of new plugin types.\n\t\treturn errors.New(\"Plugin.Name must not be empty\")\n\t}\n\n\td.pluginsLock.Lock()\n\tdefer d.pluginsLock.Unlock()\n\n\tpmap, ok := d.plugins[info.Type]\n\tif !ok {\n\t\tpmap = make(map[string]*list.List)\n\t\td.plugins[info.Type] = pmap\n\t}\n\tinfos, ok := pmap[info.Name]\n\tif !ok {\n\t\tinfos = list.New()\n\t\tpmap[info.Name] = infos\n\t}\n\n\t// TODO(tgross): https://github.com/hashicorp/nomad/issues/11786\n\t// If we're already registered, we should update the definition","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/dynamicplugins/registry.go#L168-L204","documentation":"RegisterPlugin validates the PluginInfo struct before storing it in the dynamic plugin registry. An empty Name field means the plugin registration lacks a unique identifier, so the registry rejects it. The in-code comment notes this error is meant to aid developers creating new plugin types, not to appear in production clusters.","triggerScenarios":"Calling client dynamicplugins Registry.RegisterPlugin with a *dynamicplugins.PluginInfo whose Name field is the empty string (typically constructed programmatically by a new plugin type registration handler).","commonSituations":"Developing a new dynamic plugin type (e.g. CSI or host volume plugin) where the registration handler forgets to set PluginInfo.Name, or builds it from a config value that is empty.","solutions":["Set the Name field on the dynamicplugins.PluginInfo before calling RegisterPlugin","Derive the name from the plugin's config/ID and validate it is non-empty at construction","Add a unit test for the registration handler that asserts Name is populated"],"exampleFix":"// before\ninfo := &dynamicplugins.PluginInfo{Type: dynamicplugins.PluginTypeCSIDriver, ConnectionInfo: connInfo}\nerr := registry.RegisterPlugin(info)\n// after\ninfo := &dynamicplugins.PluginInfo{Type: dynamicplugins.PluginTypeCSIDriver, Name: driverName, ConnectionInfo: connInfo}\nif info.Name == \"\" {\n    return fmt.Errorf(\"plugin name is required\")\n}\nerr := registry.RegisterPlugin(info)","handlingStrategy":"validation","validationCode":"if info == nil || info.Name == \"\" {\n    return fmt.Errorf(\"cannot register plugin of type %s: name is required\", info.Type)\n}\nerr := registry.RegisterPlugin(info)","typeGuard":"func validPluginInfo(info *dynamicplugins.PluginInfo) bool {\n    return info != nil && info.Name != \"\" && info.Type != \"\" && info.ConnectionInfo != nil\n}","tryCatchPattern":null,"preventionTips":["Always populate PluginInfo.Name from a validated config value at construction time","Add constructor helpers that reject empty names before building PluginInfo","Write registration-handler unit tests asserting non-empty Name"],"tags":["validation","plugin-registry","nomad"],"backgroundTag":"empty-required-field","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}