hashicorp/nomad · error

Task group name contains null character

Error message

Task group name contains null character

What it means

TaskGroup.Validate rejects task group names containing the NUL character (\000), since names are used in internal keys, allocation identifiers, and service discovery entries where null bytes are illegal.

Source

Thrown at nomad/structs/structs.go:7130

	}
	for _, task := range tg.Tasks {
		for _, service := range task.Services {
			if f(service) {
				services = append(services, service)
			}
		}
	}
	return services
}

// 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 {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Sanitize group names, stripping control characters before submitting.
  2. Validate names against a safe pattern (letters, digits, dashes) at intake.
  3. Use nomad job validate on generated specs.

Example fix

// before
name := strings.ReplaceAll(userInput, "\x00", "") // was missing
// after
if strings.Contains(name, "\x00") { return fmt.Errorf("invalid group name") }
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

func safeName(s string) bool { return s != "" && !strings.ContainsAny(s, "\x00") }

Prevention

When it happens

Trigger: Submitting a job whose group name contains a literal \u0000, usually from untrusted/unsanitized input interpolated into the name.

Common situations: Generating group names from user input or environment data that includes null bytes; JSON parsing of malformed input embedding \u0000.

Related errors


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