{"record":{"id":"844188148278b351","repo":"hashicorp/nomad","slug":"namespace-s-does-not-exist","errorCode":null,"errorMessage":"namespace %s does not exist","messagePattern":"namespace (.+?) does not exist","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/namespace_endpoint.go","lineNumber":307,"sourceCode":"\t\tif raw == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tv := raw.(*structs.VariableEncrypted)\n\t\tif v.VariableMetadata.Namespace == namespace {\n\t\t\treturn false, nil\n\t\t}\n\t}\n\n\treturn true, nil\n}\n\n// namespaceNoAssociatedQuotasLocally returns true if there are no quotas\n// associated with this namespace in the local region\nfunc (n *Namespace) namespaceNoAssociatedQuotasLocally(namespace string, snap *state.StateSnapshot) (bool, error) {\n\tns, _ := snap.NamespaceByName(nil, namespace)\n\tif ns == nil {\n\t\treturn false, fmt.Errorf(\"namespace %s does not exist\", namespace)\n\t}\n\tif ns.Quota != \"\" {\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}\n\n// namespaceTerminalJobsInRegion returns true if the namespace contains only\n// terminal jobs in the given region.\nfunc (n *Namespace) namespaceTerminalJobsInRegion(authToken, namespace, region string) (bool, error) {\n\tjobReq := &structs.JobListRequest{\n\t\tQueryOptions: structs.QueryOptions{\n\t\t\tRegion:     region,\n\t\t\tNamespace:  namespace,\n\t\t\tAllowStale: false,\n\t\t\tAuthToken:  authToken,\n\t\t},","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/namespace_endpoint.go#L289-L325","documentation":"namespaceNoAssociatedQuotasLocally looks up the namespace in the state snapshot to check whether a quota spec is attached. If the namespace record is absent, the check cannot proceed and it returns 'namespace %s does not exist'. This surfaces when a caller requests deletion of a namespace that was already removed or never created.","triggerScenarios":"Calling Namespace.Delete (or related validation) with a namespace name not present in the state store; double-delete after a first successful delete; a typo in the namespace name.","commonSituations":"Concurrent scripts/operators deleting the same namespace; stale configs or caches referencing a namespace deleted earlier; typos in IaC templates.","solutions":["Verify the namespace exists first (nomad namespace inspect <name> or GET /v1/namespace/<name>).","Skip deletion for names that return not-found instead of failing.","Fix the namespace name in the request/config if it was a typo."],"exampleFix":"// before\nclient.Namespaces().Delete(&api.NamespaceDeleteRequest{Namespaces: names})\n// after\nvar existing []string\nfor _, n := range names {\n    if _, _, err := client.Namespaces().Info(n, nil); err == nil { existing = append(existing, n) }\n}\nclient.Namespaces().Delete(&api.NamespaceDeleteRequest{Namespaces: existing})","handlingStrategy":"validation","validationCode":"_, _, err := client.Namespaces().Info(name, nil)\nif err != nil { return nil } // already gone; skip delete\n_, err = client.Namespaces().Delete(&api.NamespaceDeleteRequest{Namespaces: []string{name}})","typeGuard":"func namespaceExists(c *api.Client, name string) bool {\n    _, _, err := c.Namespaces().Info(name, nil)\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["Check existence before deleting; treat not-found as success for idempotent cleanup.","Use idempotent delete helpers that tolerate missing resources.","Validate names against the cluster listing to catch typos early."],"tags":["nomad","namespace","not-found"],"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"}