{"record":{"id":"c7978dab2a474a61","repo":"hashicorp/nomad","slug":"job-q-in-namespace-q-not-found","errorCode":null,"errorMessage":"job %q in namespace %q not found","messagePattern":"job %q in namespace %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/plan_endpoint.go","lineNumber":60,"sourceCode":"\t\treturn fmt.Errorf(\"cannot submit nil plan\")\n\t}\n\n\tplan := args.Plan\n\tif plan.Job == nil {\n\t\tif plan.JobInfo == nil {\n\t\t\treturn fmt.Errorf(\"cannot submit plan without job info\")\n\t\t}\n\n\t\t// we lookup the job immediately after the plan submission is requested,\n\t\t// in order to save time not having to look it up whenever needed and\n\t\t// more importantly, to avoid nil jobs in the plan in situations when\n\t\t// job gets dropped from the state store while plan is still in flight.\n\t\tjob, err := p.srv.State().JobByID(nil, plan.JobInfo.Namespace, plan.JobInfo.ID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif job == nil {\n\t\t\treturn fmt.Errorf(\"job %q in namespace %q not found\", plan.JobInfo.ID, plan.JobInfo.Namespace)\n\t\t}\n\t\tplan.Job = job\n\t}\n\n\t// Pause the Nack timer for the eval as it is making progress as long as it\n\t// is in the plan queue. We resume immediately after we get a result to\n\t// handle the case that the receiving worker dies.\n\tid := plan.EvalID\n\ttoken := plan.EvalToken\n\tif err := p.srv.evalBroker.PauseNackTimeout(id, token); err != nil {\n\t\treturn err\n\t}\n\tdefer p.srv.evalBroker.ResumeNackTimeout(id, token)\n\n\t// Submit the plan to the queue\n\tfuture, err := p.srv.planQueue.Enqueue(plan)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/plan_endpoint.go#L42-L78","documentation":"When a plan arrives with only JobInfo (no embedded Job), the leader looks the job up in the state store by namespace and ID. If the job no longer exists — it was dropped while the plan was in flight — the handler returns this error rather than processing a plan for a missing job.","triggerScenarios":"Plan.Submit with plan.Job==nil whose plan.JobInfo.Namespace/ID do not match any job in the state store at submit time — e.g. the job was deregistered between eval creation and plan application.","commonSituations":"Job deleted (nomad job stop) while its evaluations/plans were still being processed; aggressive cleanup scripts deleting jobs during deployments; race after `nomad job purge`.","solutions":["Re-check job existence before relying on in-flight plans; re-submit an evaluation after re-registering the job","Avoid deleting jobs while their evaluations are pending; deregister gracefully and let evals drain","Retry plan submission after re-registering the job with the same ID/namespace","Verify namespace and ID in JobInfo match the actual registered job (typos yield the same error)"],"exampleFix":"// before\njob, _ := state.JobByID(nil, ns, id)\nsubmitPlan(plan) // plan for job already deleted\n// after\njob, _ := state.JobByID(nil, ns, id)\nif job == nil {\n    _, _ = jobs.Register(registerReq) // re-register before planning\n}\nsubmitPlan(plan)","handlingStrategy":"validation","validationCode":"job, err := state.JobByID(nil, ns, id)\nif err != nil || job == nil {\n    // re-register job or abort plan submission\n}","typeGuard":null,"tryCatchPattern":"if err := submitPlan(plan); err != nil && strings.Contains(err.Error(), \"not found\") {\n    // re-register the job then resubmit the plan\n    if _, rerr := client.Jobs().Register(regReq, nil); rerr == nil {\n        err = submitPlan(plan)\n    }\n}","preventionTips":["Avoid deleting jobs while their evals/plans are in flight","Confirm namespace and ID in JobInfo are exact","Deregister gracefully and let evals drain before purging"],"tags":["nomad","rpc","plan","state-store","race-condition"],"backgroundTag":"job-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"}