{"record":{"id":"54c264b77541b156","repo":"hashicorp/nomad","slug":"job-task-group-d-redefines-s-from-group-d","errorCode":null,"errorMessage":"Job task group %d redefines '%s' from group %d","messagePattern":"Job task group (.+?) redefines '(.+?)' from group (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":4830,"sourceCode":"\tif j.UI != nil {\n\t\tif len(j.UI.Description) > MaxDescriptionCharacters {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"UI description must be under 1000 characters, currently %d\", len(j.UI.Description)))\n\t\t}\n\t}\n\n\tif j.VersionTag != nil {\n\t\tif len(j.VersionTag.Description) > MaxDescriptionCharacters {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Tagged version description must be under 1000 characters, currently %d\", len(j.VersionTag.Description)))\n\t\t}\n\t}\n\n\t// Check for duplicate task groups\n\ttaskGroups := make(map[string]int)\n\tfor idx, tg := range j.TaskGroups {\n\t\tif tg.Name == \"\" {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Job task group %d missing name\", idx+1))\n\t\t} else if existing, ok := taskGroups[tg.Name]; ok {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Job task group %d redefines '%s' from group %d\", idx+1, tg.Name, existing+1))\n\t\t} else {\n\t\t\ttaskGroups[tg.Name] = idx\n\t\t}\n\n\t\tif tg.ShutdownDelay != nil && *tg.ShutdownDelay < 0 {\n\t\t\tmErr.Errors = append(mErr.Errors, errors.New(\"ShutdownDelay must be a positive value\"))\n\t\t}\n\n\t\tif j.Type == \"system\" && tg.Count > 1 {\n\t\t\tmErr.Errors = append(mErr.Errors,\n\t\t\t\tfmt.Errorf(\"Job task group %s has count %d. Count cannot exceed 1 with system scheduler\",\n\t\t\t\t\ttg.Name, tg.Count))\n\t\t}\n\t}\n\n\t// Validate the task group\n\tfor _, tg := range j.TaskGroups {\n\t\tif err := tg.Validate(j); err != nil {","sourceCodeStart":4812,"sourceCodeEnd":4848,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L4812-L4848","documentation":"Job.Validate() enforces unique task group names: if tg.Name was already seen in an earlier group, it appends 'Job task group %d redefines %s from group %d' with 1-based indices. Duplicate group names would make allocations and job state ambiguous.","triggerScenarios":"Submitting a job where two or more group blocks share the same name, e.g. duplicated group blocks from templating or merged job files.","commonSituations":"YAML/HCL template loops rendering the same group name twice, concatenating job fragments, copy-pasting a group block and forgetting to rename it.","solutions":["Rename the duplicate group at the given index to a unique name","De-duplicate group generation in your templating logic","Run 'nomad job validate' in CI to catch duplicates before submit","Use the reported indices (current group and original group) to locate the clash"],"exampleFix":"// before\ngroup \"web\" {}\ngroup \"web\" {}\n// after\ngroup \"web\" {}\ngroup \"web-admin\" {}","handlingStrategy":"validation","validationCode":"seen := map[string]bool{}\nfor _, tg := range job.TaskGroups {\n    if seen[tg.Name] {\n        return fmt.Errorf(\"duplicate task group name %q\", tg.Name)\n    }\n    seen[tg.Name] = true\n}\nreturn nil","typeGuard":"func uniqueGroupNames(j *structs.Job) bool {\n    seen := make(map[string]struct{}, len(j.TaskGroups))\n    for _, tg := range j.TaskGroups {\n        if _, ok := seen[tg.Name]; ok {\n            return false\n        }\n        seen[tg.Name] = struct{}{}\n    }\n    return true\n}","tryCatchPattern":"if err := job.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"redefines\") {\n        return ErrDuplicateGroupName\n    }\n    return err\n}","preventionTips":["De-duplicate group names in templating loops (append suffix per iteration)","Review merged job files for overlapping group blocks","Add a duplicate-name check to your job spec linter"],"tags":["nomad","job-validation","task-group","duplicate-name"],"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"}