{"record":{"id":"dc171b960ae843cd","repo":"hashicorp/nomad","slug":"csipluginconfig-must-have-a-non-empty-pluginid","errorCode":null,"errorMessage":"CSIPluginConfig must have a non-empty PluginID","messagePattern":"CSIPluginConfig must have a non-empty PluginID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":8409,"sourceCode":"\t\t\tmErr.Errors = append(mErr.Errors, serviceErr)\n\t\t}\n\t}\n\n\t// Validation for volumes\n\tfor idx, vm := range t.VolumeMounts {\n\t\tif _, ok := tg.Volumes[vm.Volume]; !ok {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Volume Mount (%d) references undefined volume %s\", idx, vm.Volume))\n\t\t}\n\n\t\tif err := vm.Validate(); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Volume Mount (%d) is invalid: \\\"%w\\\"\", idx, err))\n\t\t}\n\t}\n\n\t// Validate CSI Plugin Config\n\tif t.CSIPluginConfig != nil {\n\t\tif t.CSIPluginConfig.ID == \"\" {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"CSIPluginConfig must have a non-empty PluginID\"))\n\t\t}\n\n\t\tif !CSIPluginTypeIsValid(t.CSIPluginConfig.Type) {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"CSIPluginConfig PluginType must be one of 'node', 'controller', or 'monolith', got: \\\"%s\\\"\", t.CSIPluginConfig.Type))\n\t\t}\n\n\t\tif t.CSIPluginConfig.StagePublishBaseDir != \"\" && t.CSIPluginConfig.MountDir != \"\" &&\n\t\t\thelper.IsSubdirectory(t.CSIPluginConfig.MountDir, t.CSIPluginConfig.StagePublishBaseDir) {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"CSIPluginConfig StagePublishBaseDir must not be a subdirectory of MountDir, got: StagePublishBaseDir=\\\"%s\\\" MountDir=\\\"%s\\\"\", t.CSIPluginConfig.StagePublishBaseDir, t.CSIPluginConfig.MountDir))\n\t\t}\n\n\t\t// TODO: Investigate validation of the PluginMountDir. Not much we can do apart from check IsAbs until after we understand its execution environment though :(\n\t}\n\n\t// Validate default Identity\n\tif t.Identity != nil {\n\t\tif err := t.Identity.Validate(); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Identity %q is invalid: %w\", t.Identity.Name, err))","sourceCodeStart":8391,"sourceCodeEnd":8427,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L8391-L8427","documentation":"During Task.Validate in nomad/structs/structs.go, if a task declares a csi_plugin block, the CSIPluginConfig.ID (PluginID) must be non-empty. Nomad cannot route volume/plugin operations without knowing which CSI plugin the task deploys or uses. The check is a plain empty-string test on CSIPluginConfig.ID.","triggerScenarios":"Submitting a job whose task has a csi_plugin { } block that omits the id field, or sets id = \"\"; programmatic construction of a Task with CSIPluginConfig non-nil but ID unset (e.g. via jobspec parsing or the Go API).","commonSituations":"HCL jobspec missing the id argument inside csi_plugin; templating a job where the plugin id variable renders empty; API clients building Task structs that set CSIPluginConfig.Type but forget ID.","solutions":["Set the id field inside the task's csi_plugin block to the plugin's CSIPluginName (the plugin_id of the registered CSI plugin)","Verify with `nomad plugin status` which plugin ID to use and copy it exactly","If the task is not meant to deploy a CSI plugin, remove the csi_plugin block entirely"],"exampleFix":"// before\ncsi_plugin {\n  type = \"node\"\n}\n// after\ncsi_plugin {\n  id   = \"aws-efs0\"\n  type = \"node\"\n}","handlingStrategy":"validation","validationCode":"if t.CSIPluginConfig != nil && t.CSIPluginConfig.ID == \"\" {\n    return errors.New(\"csi_plugin requires a non-empty id (plugin ID)\")\n}","typeGuard":"func hasPluginID(cfg *structs.CSIPluginConfig) bool { return cfg != nil && strings.TrimSpace(cfg.ID) != \"\" }","tryCatchPattern":null,"preventionTips":["Always set id in csi_plugin blocks; keep a template with id filled","Look up plugin IDs with `nomad plugin status` before authoring jobs","Run `nomad job validate` in CI before job submission"],"tags":["nomad","csi","validation","jobspec"],"backgroundTag":"missing-required-argument","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"}