{"record":{"id":"5e2b6475183ea29c","repo":"hashicorp/nomad","slug":"job-q-not-found","errorCode":null,"errorMessage":"job %q not found","messagePattern":"job %q not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/job_endpoint.go","lineNumber":578,"sourceCode":"\t}\n\n\t// Validate the arguments\n\tif args.JobID == \"\" {\n\t\treturn fmt.Errorf(\"missing job ID for revert\")\n\t}\n\n\t// Lookup the job by version\n\tsnap, err := j.srv.fsm.State().Snapshot()\n\tif err != nil {\n\t\treturn err\n\t}\n\tws := memdb.NewWatchSet()\n\tcur, err := snap.JobByID(ws, args.RequestNamespace(), args.JobID)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif cur == nil {\n\t\treturn fmt.Errorf(\"job %q not found\", args.JobID)\n\t}\n\tif args.JobVersion == cur.Version {\n\t\treturn fmt.Errorf(\"can't revert to current version\")\n\t}\n\n\tjobV, err := snap.JobByIDAndVersion(ws, args.RequestNamespace(), args.JobID, args.JobVersion)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif jobV == nil {\n\t\treturn fmt.Errorf(\"job %q in namespace %q at version %d not found\", args.JobID, args.RequestNamespace(), args.JobVersion)\n\t}\n\n\t// Build the register request\n\trevJob := jobV.Copy()\n\n\t// Clear out the VersionTag to prevent tag duplication\n\trevJob.VersionTag = nil","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/job_endpoint.go#L560-L596","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (wrong namespace)\nclient.Jobs().Revert(\"webapp\", 3, 5, nil, nil, nil)\n// after\nq := &nomad.WriteOptions{Namespace: \"prod\"}\nclient.Jobs().Revert(\"webapp\", 3, 5, nil, nil, q)","handlingStrategy":"validation","validationCode":"job, _, err := client.Jobs().Info(jobID, &nomad.QueryOptions{Namespace: ns})\nif err != nil || job == nil {\n    return fmt.Errorf(\"job %q not present in namespace %s; skip revert\", jobID, ns)\n}","typeGuard":"func jobExists(j *api.Job) bool { return j != nil && j.ID != nil && *j.ID != \"\" }","tryCatchPattern":"job, _, err := client.Jobs().Revert(jobID, cur, target, nil, nil, wo)\nif err != nil && strings.Contains(err.Error(), \"not found\") {\n    // job absent in this namespace: re-register instead of reverting\n}","preventionTips":["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"],"tags":["nomad","job-revert","not-found","state-store"],"backgroundTag":"resource-not-found","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}