hashicorp/nomad · error
Missing tasks for task group
Error message
Missing tasks for task group
What it means
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.
Source
Thrown at nomad/structs/structs.go:7139
}
// Validate is used to check a task group for reasonable configuration
func (tg *TaskGroup) Validate(j *Job) error {
var mErr *multierror.Error
if tg.Name == "" {
mErr = multierror.Append(mErr, errors.New("Missing task group name"))
} else if strings.Contains(tg.Name, "\000") {
mErr = multierror.Append(mErr, errors.New("Task group name contains null character"))
}
if tg.Count < 0 {
mErr = multierror.Append(mErr, errors.New("Task group count can't be negative"))
}
if len(tg.Tasks) == 0 {
// could be a lone consul gateway inserted by the connect mutator
mErr = multierror.Append(mErr, errors.New("Missing tasks for task group"))
}
if tg.Disconnect != nil {
if err := tg.Disconnect.Validate(j); err != nil {
mErr = multierror.Append(mErr, err)
}
}
if tg.MaxRunDuration != nil {
if *tg.MaxRunDuration <= 0 {
mErr = multierror.Append(mErr, errors.New("MaxRunDuration must be greater than zero"))
}
switch j.Type {
case JobTypeBatch, JobTypeSysBatch:
default:
mErr = multierror.Append(mErr, fmt.Errorf("Job type %q does not allow max_run_duration", j.Type))
}View on GitHub (pinned to 482b49bf1a)
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).
Example fix
// before
group "batch" {
max_run_duration = 0
}
// after
group "batch" {
max_run_duration = "1h"
} Defensive patterns
Strategy: validation
Validate before calling
if tg.MaxRunDuration != nil && *tg.MaxRunDuration <= 0 {
return fmt.Errorf("max_run_duration must be > 0, got %s", tg.MaxRunDuration)
} Type guard
func validMaxRunDuration(d *time.Duration) bool { return d == nil || *d > 0 } Prevention
- Leave max_run_duration unset unless needed
- Use positive duration literals in HCL
- Clamp templated durations to a positive minimum
When it happens
Trigger: Submitting a batch or sysbatch job where max_run_duration is set to 0 or a negative duration in a group.
Common situations: Templated durations evaluating to 0s; sign errors in computed values; misunderstanding the default (leaving it nil is fine — only explicitly invalid values fail).
Related errors
- ErrConnectRequireOneNetwork
- ErrConnectInvalidNetworkMode
- service.port must be set for mesh gateway service
- non-default Consul cluster requires Nomad Enterprise
- numa scheduling requires Nomad Enterprise
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/4cf6f8cc30020ba5.
Report an issue: GitHub.