{"record":{"id":"4cf6f8cc30020ba5","repo":"hashicorp/nomad","slug":"missing-tasks-for-task-group","errorCode":null,"errorMessage":"Missing tasks for task group","messagePattern":"Missing tasks for task group","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7139,"sourceCode":"}\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}\n\n\tif tg.MaxRunDuration != nil {\n\t\tif *tg.MaxRunDuration <= 0 {\n\t\t\tmErr = multierror.Append(mErr, errors.New(\"MaxRunDuration must be greater than zero\"))\n\t\t}\n\n\t\tswitch j.Type {\n\t\tcase JobTypeBatch, JobTypeSysBatch:\n\t\tdefault:\n\t\t\tmErr = multierror.Append(mErr, fmt.Errorf(\"Job type %q does not allow max_run_duration\", j.Type))\n\t\t}","sourceCodeStart":7121,"sourceCodeEnd":7157,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7121-L7157","documentation":"Group-level MaxRunDuration is deprecated/being validated to be positive; Nomad appends this error when the field is set to a zero or negative duration. MaxRunDuration caps how long an allocation may run (used with batch/system-batch jobs), so it must be > 0.","triggerScenarios":"Submitting a batch or sysbatch job where max_run_duration is set to 0 or a negative duration in a group.","commonSituations":"Templated durations evaluating to 0s; sign errors in computed values; misunderstanding the default (leaving it nil is fine — only explicitly invalid values fail).","solutions":["Set max_run_duration to a positive duration, e.g. \"1h\".","Remove the field to leave it unset (nil).","Only use max_run_duration on batch/sysbatch job types (otherwise a separate type error fires)."],"exampleFix":"// before\ngroup \"batch\" {\n  max_run_duration = 0\n}\n// after\ngroup \"batch\" {\n  max_run_duration = \"1h\"\n}","handlingStrategy":"validation","validationCode":"if tg.MaxRunDuration != nil && *tg.MaxRunDuration <= 0 {\n    return fmt.Errorf(\"max_run_duration must be > 0, got %s\", tg.MaxRunDuration)\n}","typeGuard":"func validMaxRunDuration(d *time.Duration) bool { return d == nil || *d > 0 }","tryCatchPattern":null,"preventionTips":["Leave max_run_duration unset unless needed","Use positive duration literals in HCL","Clamp templated durations to a positive minimum"],"tags":["nomad","job-validation","invalid-duration-value"],"backgroundTag":"invalid-duration-value","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"}