{"record":{"id":"460213a021bd034d","repo":"hashicorp/nomad","slug":"job-q-is-in-nonexistent-namespace-q-460213","errorCode":null,"errorMessage":"job %q is in nonexistent namespace %q","messagePattern":"job %q is in nonexistent namespace %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store.go","lineNumber":1807,"sourceCode":"// UpsertJobWithRequest is used to register a job or update a job definition\n// using the JobRegisterRequest. It allows flags to be set and used within the\n// upsert job action\nfunc (s *StateStore) UpsertJobWithRequest(msgType structs.MessageType, index uint64, req *structs.JobRegisterRequest) error {\n\ttxn := s.db.WriteTxnMsgT(msgType, index)\n\tdefer txn.Abort()\n\tif err := s.upsertJobImpl(index, req.Submission, req.Job, false, txn, req); err != nil {\n\t\treturn err\n\t}\n\treturn txn.Commit()\n}\n\n// upsertJobImpl is the implementation for registering a job or updating a job definition\nfunc (s *StateStore) upsertJobImpl(index uint64, sub *structs.JobSubmission, job *structs.Job, keepVersion bool, txn *txn, req *structs.JobRegisterRequest) error {\n\t// Assert the namespace exists\n\tif exists, err := s.namespaceExists(txn, job.Namespace); err != nil {\n\t\treturn err\n\t} else if !exists {\n\t\treturn fmt.Errorf(\"job %q is in nonexistent namespace %q\", job.ID, job.Namespace)\n\t}\n\n\t// Upgrade path.\n\t// Assert the node pool is set and exists.\n\tif job.NodePool == \"\" {\n\t\tjob.NodePool = structs.NodePoolDefault\n\t}\n\tif exists, err := s.nodePoolExists(txn, job.NodePool); err != nil {\n\t\treturn err\n\t} else if !exists {\n\t\treturn fmt.Errorf(\"job %q is in nonexistent node pool %q\", job.ID, job.NodePool)\n\t}\n\n\t// Check if the job already exists\n\texisting, err := txn.First(\"jobs\", \"id\", job.Namespace, job.ID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"job lookup failed: %v\", err)\n\t}","sourceCodeStart":1789,"sourceCodeEnd":1825,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L1789-L1825","documentation":"upsertJobImpl refused to register the job because its namespace does not exist in the state store; jobs can only be upserted into a namespace that has been created.","triggerScenarios":"Thrown at nomad/state/state_store.go:1807 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the namespace first (`nomad namespace apply`)","Register the job into an existing namespace","Check for typos in the job's namespace field"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}