{"record":{"id":"9213e8cef9d24d11","repo":"hashicorp/nomad","slug":"missing-task-group-name","errorCode":null,"errorMessage":"Missing task group name","messagePattern":"Missing task group name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7128,"sourceCode":"\t\t\tservices = append(services, service)\n\t\t}\n\t}\n\tfor _, task := range tg.Tasks {\n\t\tfor _, service := range task.Services {\n\t\t\tif f(service) {\n\t\t\t\tservices = append(services, service)\n\t\t\t}\n\t\t}\n\t}\n\treturn services\n}\n\n// Validate is used to check a task group for reasonable configuration\nfunc (tg *TaskGroup) Validate(j *Job) error {\n\tvar mErr *multierror.Error\n\n\tif tg.Name == \"\" {\n\t\tmErr = multierror.Append(mErr, errors.New(\"Missing task group name\"))\n\t} else if strings.Contains(tg.Name, \"\\000\") {\n\t\tmErr = multierror.Append(mErr, errors.New(\"Task group name contains null character\"))\n\t}\n\n\tif tg.Count < 0 {\n\t\tmErr = multierror.Append(mErr, errors.New(\"Task group count can't be negative\"))\n\t}\n\n\tif len(tg.Tasks) == 0 {\n\t\t// could be a lone consul gateway inserted by the connect mutator\n\t\tmErr = multierror.Append(mErr, errors.New(\"Missing tasks for task group\"))\n\t}\n\n\tif tg.Disconnect != nil {\n\t\tif err := tg.Disconnect.Validate(j); err != nil {\n\t\t\tmErr = multierror.Append(mErr, err)\n\t\t}\n\t}","sourceCodeStart":7110,"sourceCodeEnd":7146,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7110-L7146","documentation":"TaskGroup.Validate requires every task group to have a non-empty Name; Nomad uses the group name to build allocation IDs, service names, and Consul entries. An empty name makes the job spec unaddressable, so validation fails immediately.","triggerScenarios":"Submitting a job where a group stanza has no name, or building the JSON API TaskGroup struct with Name left as \"\".","commonSituations":"Programmatic job construction (Go SDK / JSON) skipping the Name field; HCL blocks accidentally written without a label; templating that renders an empty name.","solutions":["Add a unique name to every group stanza, e.g. group \"web\" {}.","Set the Name field when building the TaskGroup struct in code.","Run nomad job validate to catch it before submission."],"exampleFix":"// before\ngroup {\n  count = 1\n}\n// after\ngroup \"web\" {\n  count = 1\n}","handlingStrategy":"validation","validationCode":"if tg.Name == \"\" {\n    return errors.New(\"task group requires a name\")\n}","typeGuard":"func hasGroupName(tg api.TaskGroup) bool { return tg.Name != \"\" }","tryCatchPattern":null,"preventionTips":["Always label group stanzas in HCL","Set Name explicitly when building TaskGroup structs in code","Lint generated job JSON for empty required strings"],"tags":["nomad","job-validation","missing-field"],"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"}