hashicorp/nomad · error

Missing job name

Error message

Missing job name

What it means

Job.Validate() requires a non-empty Name field. The job name is used in the UI, service discovery, and as the default job ID, so an empty name is rejected. The error is appended to the validation multierror for the job spec.

Source

Thrown at nomad/structs/structs.go:4751

	return nj
}

// Validate is used to check a job for reasonable configuration
func (j *Job) Validate() error {
	var mErr multierror.Error

	if j.Region == "" && j.Multiregion == nil {
		mErr.Errors = append(mErr.Errors, errors.New("Missing job region"))
	}
	if j.ID == "" {
		mErr.Errors = append(mErr.Errors, errors.New("Missing job ID"))
	} else if strings.Contains(j.ID, " ") {
		mErr.Errors = append(mErr.Errors, errors.New("Job ID contains a space"))
	} else if strings.Contains(j.ID, "\000") {
		mErr.Errors = append(mErr.Errors, errors.New("Job ID contains a null character"))
	}
	if j.Name == "" {
		mErr.Errors = append(mErr.Errors, errors.New("Missing job name"))
	} else if strings.Contains(j.Name, "\000") {
		mErr.Errors = append(mErr.Errors, errors.New("Job Name contains a null character"))
	}

	if j.Namespace == "" {
		mErr.Errors = append(mErr.Errors, errors.New("Job must be in a namespace"))
	}
	switch j.Type {
	case JobTypeCore, JobTypeService, JobTypeBatch, JobTypeSystem, JobTypeSysBatch:
	case "":
		mErr.Errors = append(mErr.Errors, errors.New("Missing job type"))
	default:
		mErr.Errors = append(mErr.Errors, fmt.Errorf("Invalid job type: %q", j.Type))
	}
	if len(j.Datacenters) == 0 && !j.IsMultiregion() {
		mErr.Errors = append(mErr.Errors, errors.New("Missing job datacenters"))
	} else {
		for _, v := range j.Datacenters {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Provide a name in the job file: `job "web-app" { ... }`
  2. Ensure template variables used for the job name resolve to a non-empty value
  3. Set job.Name explicitly when constructing structs.Job in Go

Example fix

// before
job "" {
  ...
}
// after
job "web-app" {
  ...
}
Defensive patterns

Strategy: validation

Validate before calling

if j.Name == "" {
    return fmt.Errorf("job name must be set before submission")
}

Type guard

func hasJobName(j *structs.Job) bool { return j != nil && j.Name != "" }

Try / catch

if err := job.Validate(); err != nil {
    if strings.Contains(err.Error(), "Missing job name") {
        return fmt.Errorf("job spec is missing the required name: %w", err)
    }
}

Prevention

When it happens

Trigger: Submitting a job via `nomad job run` or POST /v1/jobs where the HCL `job` block's name (the identifier after the `job` keyword) is empty, or constructing a structs.Job with j.Name == "" and calling Validate().

Common situations: Templated HCL where the job name variable renders empty; copying a job file and deleting the name line; API payloads that omit the Name field entirely.

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/9f5c98b3547b608d. Report an issue: GitHub.