{"record":{"id":"32750259f7a2c5c0","repo":"hashicorp/nomad","slug":"job-q-is-in-nonexistent-namespace-q","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/job_endpoint_validators.go","lineNumber":28,"sourceCode":"\t\"github.com/hashicorp/nomad/nomad/structs\"\n)\n\ntype jobNamespaceConstraintCheckHook struct {\n\tsrv *Server\n}\n\nfunc (jobNamespaceConstraintCheckHook) Name() string {\n\treturn \"namespace-constraint-check\"\n}\n\nfunc (c jobNamespaceConstraintCheckHook) Validate(job *structs.Job) (warnings []error, err error) {\n\t// This was validated before and matches the WriteRequest namespace\n\tns, err := c.srv.State().NamespaceByName(nil, job.Namespace)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif ns == nil {\n\t\treturn nil, fmt.Errorf(\"job %q is in nonexistent namespace %q\", job.ID, job.Namespace)\n\t}\n\n\tvar disallowedDrivers []string\n\tfor _, tg := range job.TaskGroups {\n\t\tfor _, t := range tg.Tasks {\n\t\t\tif !taskValidateDriver(t, ns) {\n\t\t\t\tdisallowedDrivers = append(disallowedDrivers, t.Driver)\n\t\t\t}\n\t\t}\n\t}\n\tif len(disallowedDrivers) > 0 {\n\t\tif len(disallowedDrivers) == 1 {\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"used task driver %q is not allowed in namespace %q\", disallowedDrivers[0], ns.Name,\n\t\t\t)\n\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/job_endpoint_validators.go#L10-L46","documentation":"This job validator confirms the job's namespace actually exists in state store before applying namespace-scoped checks (drivers, network modes). If NamespaceByName returns nil, the job references a namespace that was never created, and registration is rejected with this error.","triggerScenarios":"Submitting a job with namespace = \"foo\" when namespace \"foo\" has not been created. Raised in Validate (job_endpoint_validators.go) on every job register that passes through this hook.","commonSituations":"Job files copied between clusters where the target cluster lacks the namespace; namespace deleted while jobs referencing it are re-registered; typo in namespace name; CI deploys jobs before namespace bootstrap step runs.","solutions":["Create the namespace first: nomad namespace create <name> or via the namespaces API","Correct the job's namespace field to an existing namespace","Ensure infrastructure-as-code ordering: namespaces provisioned before job registration"],"exampleFix":"// before\njob \"web\" { namespace = \"payments\" } // namespace missing\n// after\nnomad namespace create payments\n// or set namespace = \"default\"","handlingStrategy":"validation","validationCode":"// before submit\nns, err := client.Namespaces().Info(job.Namespace, nil)\nif err != nil || ns == nil {\n  return fmt.Errorf(\"create namespace %q first\", job.Namespace)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision namespaces as a prerequisite step in deployment pipelines","Use a CI preflight that lists namespaces and cross-checks job specs","Avoid hardcoding namespaces; source them from environment config"],"tags":["nomad","namespace","job-validation","state-store"],"backgroundTag":"nonexistent-namespace","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"}