hashicorp/nomad · error · RegisterEnforceIndexErrPrefix
%s %d: job does not exist
Error message
%s %d: job does not exist
What it means
Job.EnforceIndex compare-and-set check: when the job does NOT exist in state but the caller requested a non-zero index, registration fails because a non-zero index asserts 'job exists with this modify index'. Prefixed with RegisterEnforceIndexErrPrefix.
Source
Thrown at nomad/structs/job.go:317
break // to next TaskGroup
}
}
}
return result
}
// EnforceIndex checks the `EnforceIndex` logic: if the job exists (not `nil`)
// it must match the `index` argument and if `index == 0` the job must be `nil`.
func (j *Job) EnforceIndex(index uint64) error {
if j != nil {
if index == 0 {
return fmt.Errorf("%s 0: job already exists", RegisterEnforceIndexErrPrefix)
} else if index != j.JobModifyIndex {
return fmt.Errorf("%s %d: job exists with conflicting job modify index: %d",
RegisterEnforceIndexErrPrefix, index, j.JobModifyIndex)
}
} else if index != 0 {
return fmt.Errorf("%s %d: job does not exist", RegisterEnforceIndexErrPrefix, index)
}
return nil
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Register once with EnforceIndex=0 (create-only) or EnforceIndex disabled to create the job
- Verify the namespace and job ID match the intended existing job
- Make deployment scripts handle both create and update cases
Example fix
// before EnforceIndex: true, JobModifyIndex: 7 // update-only, job absent // after EnforceIndex: true, JobModifyIndex: 0 // create-only path
Defensive patterns
Strategy: validation
Validate before calling
_, _, err := client.Jobs().Info(jobID)
jobExists := err == nil
if !jobExists && opts.JobModifyIndex > 0 {
return errors.New("job does not exist; cannot EnforceIndex with nonzero value")
} Try / catch
_, _, err := client.Jobs().Register(job, &api.RegisterOptions{EnforceIndex: true, JobModifyIndex: idx})
if err != nil && strings.Contains(err.Error(), "job does not exist") {
// register with JobModifyIndex 0 to create
} Prevention
- Check job existence before issuing an update-only register
- Make create/update flows explicit in CI scripts
- Confirm namespace and job ID spelling
When it happens
Trigger: Job register with EnforceIndex=true and EnforceIndex > 0 for a job ID/namespace that has never been created (or was purged).
Common situations: Update-only deploy script run before the job was ever created; job purged or GC'd between read and write; wrong namespace in the register request.
Related errors
- %s 0: job already exists
- %s %d: job exists with conflicting job modify index: %d
- error parsing: root should be an object
- missing policy name
- cannot specify Accessor ID
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/eb75c06151257c03.
Report an issue: GitHub.