hashicorp/nomad · error
Missing job type
Error message
Missing job type
What it means
Job validation guard in Job.Validate: fires when a submitted job's Type field is empty, since every job must declare service, batch, system, or sysbatch. It is a sentinel validation error collected into the multierror returned to the job-submission caller; fix by setting the job's type in the HCL/JSON spec.
Source
Thrown at nomad/structs/structs.go:4762
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 {
if v == "" {
mErr.Errors = append(mErr.Errors, errors.New("Job datacenter must be non-empty string"))
}
}
}
if len(j.TaskGroups) == 0 {
mErr.Errors = append(mErr.Errors, errors.New("Missing job task groups"))
}
for idx, constr := range j.Constraints {
if err := constr.Validate(); err != nil {View on GitHub (pinned to 482b49bf1a)
Solutions
- Add `type = "service"` (or batch/system/sysbatch) to the job file
- Set job.Type = "service" explicitly when building the job programmatically
- Verify templated HCL renders the type stanza for all branches
Example fix
// before
job "web-app" {
group "web" { ... }
}
// after
job "web-app" {
type = "service"
group "web" { ... }
} Defensive patterns
Strategy: validation
Validate before calling
validTypes := map[string]bool{"service": true, "batch": true, "system": true, "sysbatch": true, "core": true}
if !validTypes[j.Type] {
return fmt.Errorf("job type must be one of service|batch|system|sysbatch|core, got %q", j.Type)
} Type guard
func hasValidJobType(t string) bool {
switch t {
case "service", "batch", "system", "sysbatch", "core": return true
}
return false
} Try / catch
if err := job.Validate(); err != nil {
if strings.Contains(err.Error(), "Missing job type") {
return fmt.Errorf("add a type stanza (e.g. type = \"service\") to the job: %w", err)
}
} Prevention
- Always include a type stanza in job HCL
- Start job templates from `nomad init` which includes type
- Run nomad job validate before submit
When it happens
Trigger: Submitting a job spec whose `type` stanza is absent or empty via nomad job run or POST /v1/jobs; constructing structs.Job without setting Type and calling Validate().
Common situations: Hand-written HCL that forgot the `type = "service"` line; JSON job files converted from other tools lacking the type field; template errors dropping the type stanza.
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
- Missing job ID
- Job ID contains a space
- Missing job name
- Missing job task groups
- Disconnect cannot be configured with both lost_after and sto
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/2f8397d9c4d3a6f1.
Report an issue: GitHub.