{"record":{"id":"e48462926e9e727e","repo":"hashicorp/nomad","slug":"must-specify-plugin-name-to-dispense","errorCode":null,"errorMessage":"must specify plugin name to dispense","messagePattern":"must specify plugin name to dispense","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/dynamicplugins/registry.go","lineNumber":379,"sourceCode":"\t\t\tdelay = maxDelay\n\t\t}\n\t\ttimer.Reset(time.Duration(delay) * time.Millisecond)\n\t}\n}\n\nfunc (d *dynamicRegistry) DispensePlugin(ptype string, name string) (any, error) {\n\td.pluginsLock.Lock()\n\tdefer d.pluginsLock.Unlock()\n\n\tif ptype == \"\" {\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 nil, errors.New(\"must specify plugin type to dispense\")\n\t}\n\tif 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 nil, errors.New(\"must specify plugin name to dispense\")\n\t}\n\n\tdispenseFunc, ok := d.dispensers[ptype]\n\tif !ok {\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 nil, fmt.Errorf(\"no plugin dispenser found for type: %s\", ptype)\n\t}\n\n\t// After initially loading the dispenser (to avoid masking missing setup in\n\t// client/client.go), we then check to see if we have any stub dispensers for\n\t// this plugin type. If we do, then replace the dispenser fn with the stub.\n\tif d.stubDispensers != nil {\n\t\tif stub, ok := d.stubDispensers[ptype]; ok {\n\t\t\tdispenseFunc = stub\n\t\t}\n\t}\n","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/dynamicplugins/registry.go#L361-L397","documentation":"Developer-aid guard in dynamicRegistry.DispensePlugin: the plugin name argument is empty. Per the surrounding code this should not reach production clusters; it exists to catch mistakes while developing new plugin types.","triggerScenarios":"Calling Registry.DispensePlugin(ptype, \"\") with an empty plugin name, commonly when the CSI controller/node code passes a plugin name resolved from a volume request that is empty.","commonSituations":"Volume operations where the required plugin name was never populated on the volume or client request, or after renaming a plugin while old state still references it.","solutions":["Pass the plugin name exactly as registered via RegisterPlugin","Validate the name before dispensing","Verify the volume/task request carries the expected plugin name (e.g. volume.PluginID)"],"exampleFix":"// before\nplugin, err := registry.DispensePlugin(ptype, \"\")\n// after\nif name == \"\" {\n    return nil, fmt.Errorf(\"cannot dispense plugin of type %s: empty plugin name\", ptype)\n}\nplugin, err := registry.DispensePlugin(ptype, name)","handlingStrategy":"validation","validationCode":"if name == \"\" {\n    return fmt.Errorf(\"dispense: plugin name is required\")\n}\nplugin, err := registry.DispensePlugin(ptype, name)","typeGuard":"func canDispense(ptype, name string) bool {\n    return ptype != \"\" && name != \"\"\n}","tryCatchPattern":"plugin, err := registry.DispensePlugin(ptype, name)\nif err != nil {\n    if strings.Contains(err.Error(), \"must specify plugin name\") {\n        return fmt.Errorf(\"dispense failed for type %s: plugin name missing: %w\", ptype, err)\n    }\n    return err\n}","preventionTips":["Source the plugin name from volume.PluginID or equivalent required request fields","Validate required plugin name fields at request admission time","Fail fast with a clear message when the upstream name resolution yields empty"],"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"}