{"record":{"id":"0dc1d56417fe78fa","repo":"hashicorp/nomad","slug":"task-group-volume-validation-for-s-failed-v","errorCode":null,"errorMessage":"Task group volume validation for %s failed: %v","messagePattern":"Task group volume validation for (.+?) failed: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7287,"sourceCode":"\n\tif leaderTasks > 1 {\n\t\tmErr = multierror.Append(mErr, fmt.Errorf(\"Only one task may be marked as leader\"))\n\t}\n\n\t// A task group made up entirely of lifecycle tasks (prestart, poststart, or\n\t// poststop) has no main task to run, which is invalid.\n\tif len(tg.Tasks) > 0 && mainTasks == 0 {\n\t\tmErr = multierror.Append(mErr, fmt.Errorf(\"Task group %s must have at least one main task\", tg.Name))\n\t}\n\n\t// Validate the volume requests\n\tvar canaries int\n\tif tg.Update != nil {\n\t\tcanaries = tg.Update.Canary\n\t}\n\tfor name, volReq := range tg.Volumes {\n\t\tif err := volReq.Validate(j.Type, tg.Count, canaries); err != nil {\n\t\t\tmErr = multierror.Append(mErr, fmt.Errorf(\n\t\t\t\t\"Task group volume validation for %s failed: %v\", name, err))\n\t\t}\n\t}\n\n\t// Validate task group and task network resources\n\tif err := tg.validateNetworks(); err != nil {\n\t\touter := fmt.Errorf(\"Task group network validation failed: %v\", err)\n\t\tmErr = multierror.Append(mErr, outer)\n\t}\n\n\t// Validate task group and task services\n\tif err := tg.validateServices(); err != nil {\n\t\touter := fmt.Errorf(\"Task group service validation failed: %v\", err)\n\t\tmErr = multierror.Append(mErr, outer)\n\t}\n\n\t// Validate group service script-checks\n\tif err := tg.validateScriptChecksInGroupServices(); err != nil {","sourceCodeStart":7269,"sourceCodeEnd":7305,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7269-L7305","documentation":"TaskGroup.Validate runs VolumeRequest.Validate (with job type, group count, and canary count) for every entry in the group's `volume` map and wraps any failure with the volume's name in this message, appended to the job multierror. It signals a misconfigured host/CSI volume request at the task-group level.","triggerScenarios":"Submitting a job whose group `volume` block fails validation — e.g. missing required `source` for a host_volume/CSI type, invalid `type`, mount options incompatible with the volume, or count/canary constraints on read-only/CSI volumes.","commonSituations":"Referencing a host volume name typo'd or absent from the client config; mixing csi vs host volume fields; setting per_alloc on CSI volumes; Docker driver-only mount syntax errors.","solutions":["Read the wrapped inner %v error and fix the specific field in the named group `volume` block.","Verify the `source` matches a registered host_volume in client config or a registered CSI volume/plugin id.","Check type-specific constraints (e.g. access_mode/mount_options for CSI, per_alloc restrictions)."],"exampleFix":"// before\nvolume \"data\" {\n  type = \"host\"\n  # source missing\n}\n// after\nvolume \"data\" {\n  type = \"host\"\n  source = \"shared-data\"\n}","handlingStrategy":"validation","validationCode":"// Go: validate volume requests before submission\nfor name, vol := range tg.Volumes {\n  if vol.Type == \"host\" && vol.Source == \"\" {\n    return fmt.Errorf(\"group volume %q: host volume requires source\", name)\n  }\n  if vol.Type == \"csi\" && vol.Source == \"\" {\n    return fmt.Errorf(\"group volume %q: csi volume requires source (volume id)\", name)\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cross-check `source` names against client host_volume config or registered CSI volumes.","Use `nomad volume status` to confirm CSI volume registration before submitting jobs.","Keep volume blocks centralized in shared templates to avoid field drift."],"tags":["nomad","job-validation","volumes","csi"],"backgroundTag":"nomad-job-validation-failed","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"}