hashicorp/nomad · error

Task group service validation failed: %v

Error message

Task group service validation failed: %v

What it means

TaskGroup.Validate calls tg.validateServices() and wraps any failure as "Task group service validation failed: %v" before appending to the job multierror. The wrapped error comes from Service.Validate and covers malformed service definitions attached to the group (provider, name, address mode, check configuration).

Source

Thrown at nomad/structs/structs.go:7300

	if tg.Update != nil {
		canaries = tg.Update.Canary
	}
	for name, volReq := range tg.Volumes {
		if err := volReq.Validate(j.Type, tg.Count, canaries); err != nil {
			mErr = multierror.Append(mErr, fmt.Errorf(
				"Task group volume validation for %s failed: %v", name, err))
		}
	}

	// Validate task group and task network resources
	if err := tg.validateNetworks(); err != nil {
		outer := fmt.Errorf("Task group network validation failed: %v", err)
		mErr = multierror.Append(mErr, outer)
	}

	// Validate task group and task services
	if err := tg.validateServices(); err != nil {
		outer := fmt.Errorf("Task group service validation failed: %v", err)
		mErr = multierror.Append(mErr, outer)
	}

	// Validate group service script-checks
	if err := tg.validateScriptChecksInGroupServices(); err != nil {
		outer := fmt.Errorf("Task group service check validation failed: %v", err)
		mErr = multierror.Append(mErr, outer)
	}

	// Validate the scaling policy
	if err := tg.validateScalingPolicy(j); err != nil {
		outer := fmt.Errorf("Task group scaling policy validation failed: %v", err)
		mErr = multierror.Append(mErr, outer)
	}

	// Validate the tasks
	for _, task := range tg.Tasks {
		if err := task.Validate(j.Type, tg); err != nil {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Read the wrapped inner error and fix the specific field in the failing `service` block.
  2. Validate provider is exactly "consul" or "nomad" and only use fields that provider supports.
  3. Ensure service name is non-empty and contains only valid characters.

Example fix

// before
service {
  name = ""
  provider = "nomad"
  check { type = "http" address_mode = "host" }
}
// after
service {
  name = "web"
  provider = "nomad"
  check { type = "http" port = "http" }
}
Defensive patterns

Strategy: validation

Validate before calling

// Go: basic service sanity before submission
for _, s := range tg.Services {
  if s.Name == "" {
    return fmt.Errorf("service name required")
  }
  if s.Provider != "" && s.Provider != "consul" && s.Provider != "nomad" {
    return fmt.Errorf("service %q: invalid provider %q", s.Name, s.Provider)
  }
}

Prevention

When it happens

Trigger: Submitting a job with a group-level `service` block failing validation: empty/invalid service name, unsupported `provider` (not consul/nomad), invalid address_mode, bad check address/interval, using fields unsupported by the chosen provider.

Common situations: Typos in provider name; using consul-only check fields with provider = "nomad"; invalid service name characters; address mode "host" with bridge networking misunderstandings.

Related errors


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