{"record":{"id":"9bb29045ec206a93","repo":"hashicorp/nomad","slug":"missing-task-name","errorCode":null,"errorMessage":"Missing task name","messagePattern":"Missing task name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":8231,"sourceCode":"\t}\n\n\t// If there was no default identity, always create one.\n\tif t.Identity == nil {\n\t\tt.Identity = DefaultWorkloadIdentity()\n\t} else {\n\t\tt.Identity.Canonicalize()\n\t}\n}\n\nfunc (t *Task) GoString() string {\n\treturn fmt.Sprintf(\"*%#v\", *t)\n}\n\n// Validate is used to check a task for reasonable configuration\nfunc (t *Task) Validate(jobType string, tg *TaskGroup) error {\n\tvar mErr multierror.Error\n\tif t.Name == \"\" {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Missing task name\"))\n\t}\n\n\t// Tasks cannot be named \"alloc\" as this conflicts with and breaks task\n\t// filesystem isolation features.\n\tif t.Name == \"alloc\" {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Task cannot be named \\\"alloc\\\"\"))\n\t}\n\tif strings.ContainsAny(t.Name, `/\\`) {\n\t\t// We enforce this so that when creating the directory on disk it will\n\t\t// not have any slashes.\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Task name cannot include slashes\"))\n\t} else if strings.Contains(t.Name, \"\\000\") {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Task name cannot include null characters\"))\n\t}\n\tif t.Driver == \"\" {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Missing task driver\"))\n\t}\n\tif t.KillTimeout < 0 {","sourceCodeStart":8213,"sourceCodeEnd":8249,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L8213-L8249","documentation":"Task.Validate requires every task in a group to have a non-empty Name. The name is used for allocation directories, logs, and task lookup, so an unnamed task is invalid. This fires during job validation before submission.","triggerScenarios":"A task block (HCL `task \"\" { ... }` or JSON task with empty name) or a programmatically built structs.Task with Name left unset.","commonSituations":"Templated job generation where the name variable was empty; hand-edited HCL removing the label; JSON job specs missing the Name key.","solutions":["Give every task a unique, non-empty name, e.g. task \"server\".","Check template rendering so the task name variable is populated.","Run `nomad job validate` to catch it before submit."],"exampleFix":"// before\ntask \"\" {\n  driver = \"docker\"\n}\n// after\ntask \"server\" {\n  driver = \"docker\"\n}","handlingStrategy":"validation","validationCode":"for _, t := range tg.Tasks {\n  if t.Name == \"\" {\n    return fmt.Errorf(\"task in group %q has no name\", tg.Name)\n  }\n}","typeGuard":"func hasValidName(t *structs.Task) bool {\n  return t != nil && t.Name != \"\"\n}","tryCatchPattern":null,"preventionTips":["Always name tasks explicitly in HCL.","Check template variables feeding task labels.","Run `nomad job validate` in CI.","Use descriptive, unique task names per group."],"tags":["nomad","task","naming","validation"],"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"}