hashicorp/nomad · error

Missing task name

Error message

Missing task name

What it means

Task.Validate requires every task in a group to have a non-empty Name. The name is used for allocation directories, logs, and task lookup, so an unnamed task is invalid. This fires during job validation before submission.

Solutions

  1. Give every task a unique, non-empty name, e.g. task "server".
  2. Check template rendering so the task name variable is populated.
  3. Run `nomad job validate` to catch it before submit.

Example fix

// before
task "" {
  driver = "docker"
}
// after
task "server" {
  driver = "docker"
}
Defensive patterns

Strategy: validation

Validate before calling

for _, t := range tg.Tasks {
  if t.Name == "" {
    return fmt.Errorf("task in group %q has no name", tg.Name)
  }
}

Type guard

func hasValidName(t *structs.Task) bool {
  return t != nil && t.Name != ""
}

Prevention

When it happens

Trigger: A task block (HCL `task "" { ... }` or JSON task with empty name) or a programmatically built structs.Task with Name left unset.

Common situations: Templated job generation where the name variable was empty; hand-edited HCL removing the label; JSON job specs missing the Name key.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/9bb29045ec206a93. Report an issue: GitHub.

Appendix: source

Thrown at nomad/structs/structs.go:8231

	}

	// If there was no default identity, always create one.
	if t.Identity == nil {
		t.Identity = DefaultWorkloadIdentity()
	} else {
		t.Identity.Canonicalize()
	}
}

func (t *Task) GoString() string {
	return fmt.Sprintf("*%#v", *t)
}

// Validate is used to check a task for reasonable configuration
func (t *Task) Validate(jobType string, tg *TaskGroup) error {
	var mErr multierror.Error
	if t.Name == "" {
		mErr.Errors = append(mErr.Errors, errors.New("Missing task name"))
	}

	// Tasks cannot be named "alloc" as this conflicts with and breaks task
	// filesystem isolation features.
	if t.Name == "alloc" {
		mErr.Errors = append(mErr.Errors, errors.New("Task cannot be named \"alloc\""))
	}
	if strings.ContainsAny(t.Name, `/\`) {
		// We enforce this so that when creating the directory on disk it will
		// not have any slashes.
		mErr.Errors = append(mErr.Errors, errors.New("Task name cannot include slashes"))
	} else if strings.Contains(t.Name, "\000") {
		mErr.Errors = append(mErr.Errors, errors.New("Task name cannot include null characters"))
	}
	if t.Driver == "" {
		mErr.Errors = append(mErr.Errors, errors.New("Missing task driver"))
	}
	if t.KillTimeout < 0 {

View on GitHub (pinned to 482b49bf1a)