hashicorp/nomad · error
job %q not found
Error message
job %q not found
What it means
The Revert RPC rolls a job back to a previously registered version. Before doing anything it looks up the job's current registration in the state store; if no job with that ID exists in the requested namespace, it returns "job %q not found". This is a pre-condition failure: you cannot revert a job that was never registered (or has been purged from state).
Source
Thrown at nomad/job_endpoint.go:578
}
// Validate the arguments
if args.JobID == "" {
return fmt.Errorf("missing job ID for revert")
}
// Lookup the job by version
snap, err := j.srv.fsm.State().Snapshot()
if err != nil {
return err
}
ws := memdb.NewWatchSet()
cur, err := snap.JobByID(ws, args.RequestNamespace(), args.JobID)
if err != nil {
return err
}
if cur == nil {
return fmt.Errorf("job %q not found", args.JobID)
}
if args.JobVersion == cur.Version {
return fmt.Errorf("can't revert to current version")
}
jobV, err := snap.JobByIDAndVersion(ws, args.RequestNamespace(), args.JobID, args.JobVersion)
if err != nil {
return err
}
if jobV == nil {
return fmt.Errorf("job %q in namespace %q at version %d not found", args.JobID, args.RequestNamespace(), args.JobVersion)
}
// Build the register request
revJob := jobV.Copy()
// Clear out the VersionTag to prevent tag duplication
revJob.VersionTag = nilView on GitHub (pinned to 482b49bf1a)
Solutions
- Verify the job exists with `nomad job status <job-id>` (or GET /v1/job/<id> with the correct namespace header/region) before reverting
- Check the namespace: pass the correct -namespace flag or set the request namespace to where the job is registered
- If the job was stopped/purged, re-register the desired version's job file instead of reverting
- Fix typos in the job ID in scripts/CI pipelines
Example fix
// before (wrong namespace)
client.Jobs().Revert("webapp", 3, 5, nil, nil, nil)
// after
q := &nomad.WriteOptions{Namespace: "prod"}
client.Jobs().Revert("webapp", 3, 5, nil, nil, q) Defensive patterns
Strategy: validation
Validate before calling
job, _, err := client.Jobs().Info(jobID, &nomad.QueryOptions{Namespace: ns})
if err != nil || job == nil {
return fmt.Errorf("job %q not present in namespace %s; skip revert", jobID, ns)
} Type guard
func jobExists(j *api.Job) bool { return j != nil && j.ID != nil && *j.ID != "" } Try / catch
job, _, err := client.Jobs().Revert(jobID, cur, target, nil, nil, wo)
if err != nil && strings.Contains(err.Error(), "not found") {
// job absent in this namespace: re-register instead of reverting
} Prevention
- Always resolve the job via Info/Status before revert operations
- Pass the namespace explicitly in scripts and API clients
- Never assume a stopped job can be reverted — purged jobs are gone
- Pin job IDs in configuration, avoid free-text interpolation
When it happens
Trigger: Calling the Job.Revert RPC (nomad job revert via CLI/API) with a JobID that does not exist in args.RequestNamespace() — the state store lookup snap.JobByID returns nil. Also occurs when the job was deregistered (stopped jobs are eventually purged), or when the namespace in the request does not match the namespace the job lives in.
Common situations: Typo in the job ID; running the revert against the wrong namespace (e.g. default vs a team namespace); reverting a job that was purged after `nomad job stop -purge`; scripting a revert after a delete; multi-region setups where the job only exists in another region.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- eval not found
- variable doesn't exist
- unknown deployment %q
- launch not found
- Deployment ID %q couldn't be updated as it does not exist
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/5e2b6475183ea29c.
Report an issue: GitHub.