hashicorp/nomad · error
Task %d missing name
Error message
Task %d missing name
What it means
During TaskGroup.Validate, every task in the group must have a non-empty `name`. When a task is found with an empty name, Nomad appends this error (1-indexed by position in the group) to the job's multierror, since unnamed tasks cannot be scheduled, referenced by services, or reported on.
Source
Thrown at nomad/structs/structs.go:7254
case JobTypeService:
if tg.Migrate != nil {
if err := tg.Migrate.Validate(); err != nil {
mErr = multierror.Append(mErr, err)
}
}
default:
if tg.Migrate != nil {
mErr = multierror.Append(mErr, fmt.Errorf("Job type %q does not allow migrate block", j.Type))
}
}
// Check that there is only one leader task if any
tasks := make(map[string]int)
leaderTasks := 0
mainTasks := 0
for idx, task := range tg.Tasks {
if task.Name == "" {
mErr = multierror.Append(mErr, fmt.Errorf("Task %d missing name", idx+1))
} else if existing, ok := tasks[task.Name]; ok {
mErr = multierror.Append(mErr, fmt.Errorf("Task %d redefines '%s' from task %d", idx+1, task.Name, existing+1))
} else {
tasks[task.Name] = idx
}
if task.Leader {
leaderTasks++
}
if task.IsMain() {
mainTasks++
}
}
if leaderTasks > 1 {
mErr = multierror.Append(mErr, fmt.Errorf("Only one task may be marked as leader"))
}View on GitHub (pinned to 482b49bf1a)
Solutions
- Add a unique, non-empty `name` to each task block in the group.
- If generating the job via the SDK/API, set the Name field explicitly before submission.
Example fix
// before
task "" {
driver = "docker"
}
// after
task "myapp" {
driver = "docker"
} Defensive patterns
Strategy: validation
Validate before calling
// Go: check task names before submission
for _, tg := range job.TaskGroups {
for i, t := range tg.Tasks {
if t.Name == "" {
return fmt.Errorf("group %q task %d: name is required", tg.Name, i+1)
}
}
} Prevention
- Set task Name explicitly in SDK-generated jobs.
- Guard templating variables that supply task names against empty values.
- Run `nomad job validate` on generated specs before submit.
When it happens
Trigger: Submitting a job where a `task` block inside a group has no `name` field (empty string), typically from programmatic job construction or template substitution that dropped the name.
Common situations: Generating job specs in code/Golang SDK with an unset Task.Name; templating (e.g. `${task_name}` rendered empty); hand-edited HCL where the name line was deleted.
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/69fa934618a19b23.
Report an issue: GitHub.