hashicorp/nomad · error

Task name cannot include null characters

Error message

Task name cannot include null characters

What it means

Task.Validate rejects task names containing the null character "\000". Null bytes are invalid in filesystem paths and would break allocation directory creation. This branch is only evaluated when the name contains no slashes.

Source

Thrown at nomad/structs/structs.go:8244

// 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 {
		mErr.Errors = append(mErr.Errors, errors.New("KillTimeout must be a positive value"))
	} else {
		// Validate the group's update strategy does not conflict with the
		// task's kill_timeout for service jobs.
		//
		// progress_deadline = 0 has a special meaning so it should not be
		// validated against the task's kill_timeout.
		conflictsWithProgressDeadline := jobType == JobTypeService &&
			tg.Update != nil &&
			tg.Update.ProgressDeadline > 0 &&
			t.KillTimeout > tg.Update.ProgressDeadline
		if conflictsWithProgressDeadline {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("KillTimout (%s) longer than the group's ProgressDeadline (%s)",

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Strip null bytes from the task name before building the job.
  2. Sanitize any external input feeding task names.
  3. Validate before submit.

Example fix

// before
name := strings.Replace(raw, "\x00", "", -1) // never done
task.Name = raw
// after
task.Name = strings.ReplaceAll(raw, "\x00", "")
Defensive patterns

Strategy: validation

Validate before calling

if strings.Contains(t.Name, "\x00") {
  return errors.New("task name contains null characters")
}

Type guard

func hasNoNullBytes(s string) bool {
  return !strings.ContainsRune(s, '\x00')
}

Prevention

When it happens

Trigger: A task name containing a literal NUL character, typically from binary/corrupted input or unsanitized programmatic construction of structs.Task.

Common situations: Jobs built programmatically from external data where names were not sanitized; corrupt JSON payloads.

Related errors


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