{"record":{"id":"a5972faa7a6bb636","repo":"hashicorp/nomad","slug":"namespace-q-matched-no-namespaces","errorCode":null,"errorMessage":"Namespace %q matched no namespaces","messagePattern":"Namespace %q matched no namespaces","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/namespace_status.go","lineNumber":243,"sourceCode":"\t\tfmt.Sprintf(\"Disabled Drivers|%s\", disabled_drivers),\n\t\tfmt.Sprintf(\"Enabled Network Modes|%s\", enabled_network_modes),\n\t\tfmt.Sprintf(\"Disabled Network Modes|%s\", disabled_network_modes),\n\t}\n\n\treturn formatKV(basic)\n}\n\nfunc getNamespace(client *api.Namespaces, ns string) (match *api.Namespace, possible []*api.Namespace, err error) {\n\t// Do a prefix lookup\n\tnamespaces, _, err := client.PrefixList(ns, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tl := len(namespaces)\n\tswitch {\n\tcase l == 0:\n\t\treturn nil, nil, fmt.Errorf(\"Namespace %q matched no namespaces\", ns)\n\tcase l == 1:\n\t\treturn namespaces[0], nil, nil\n\tdefault:\n\t\t// search for an exact match in the returned namespaces\n\t\tfor _, namespace := range namespaces {\n\t\t\tif namespace.Name == ns {\n\t\t\t\treturn namespace, nil, nil\n\t\t\t}\n\t\t}\n\t\t// if not found, return the fuzzy matches.\n\t\treturn nil, namespaces, nil\n\t}\n}\n","sourceCodeStart":225,"sourceCodeEnd":257,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/namespace_status.go#L225-L257","documentation":"getNamespace resolves a namespace argument against the Nomad API by prefix-listing namespaces. After the query, it inspects how many namespaces matched: if none did, it throws \"Namespace %q matched no namespaces\". This is a user-input resolution error — the namespace name given to the command does not correspond to any namespace registered in the cluster.","triggerScenarios":"Running a command like `nomad namespace status <name>` (or any command routed through Run that resolves a namespace argument via getNamespace) where the PrefixList search for the given name returns zero namespaces.","commonSituations":"Typo in the namespace name; running against the wrong cluster/region (namespace exists elsewhere); the namespace was deleted or never created; using the fully-qualified or differently-cased name than what was registered.","solutions":["List existing namespaces with `nomad namespace list` and confirm the exact name.","Check you are targeting the intended cluster/region (NOMAD_ADDR, -region flags).","Create the missing namespace: `nomad namespace apply <name>`.","Re-run the command with the corrected namespace name."],"exampleFix":"// before (shell)\nnomad namespace status prod-web   // typo\n// after\nnomad namespace list              # find correct name\nnomad namespace status prod-web-1","handlingStrategy":"validation","validationCode":"// shell: verify before running\nnomad namespace list | grep -qx \"$NS\" || { echo \"namespace $NS not found\"; exit 1; }\nnomad namespace status \"$NS\"","typeGuard":null,"tryCatchPattern":"// bash: capture and branch on the error message\nif ! out=$(nomad namespace status \"$NS\" 2>&1); then\n  case \"$out\" in *\"matched no namespaces\"*) nomad namespace apply \"$NS\" ;; esac\nfi","preventionTips":["Verify namespace names with `nomad namespace list` before scripting against them.","Pin NOMAD_ADDR/-region per environment to avoid cross-cluster lookups.","Create namespaces in provisioning code (terraform/IaC) before workloads reference them."],"tags":["cli","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"}