{"record":{"id":"715dcf3f41e8e08b","repo":"derailed/k9s","slug":"namespace-not-ready","errorCode":null,"errorMessage":"namespace not ready","messagePattern":"namespace not ready","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/render/ns.go","lineNumber":115,"sourceCode":"func (n Namespace) Healthy(_ context.Context, o any) error {\n\tres, ok := o.(*unstructured.Unstructured)\n\tif !ok {\n\t\tslog.Error(\"Expected *Unstructured, but got\", slogs.Type, fmt.Sprintf(\"%T\", o))\n\t\treturn nil\n\t}\n\tvar ns v1.Namespace\n\terr := runtime.DefaultUnstructuredConverter.FromUnstructured(res.Object, &ns)\n\tif err != nil {\n\t\tslog.Error(\"Failed to convert Unstructured to Namespace\", slogs.Type, fmt.Sprintf(\"%T\", o), slog.String(\"error\", err.Error()))\n\t\treturn nil\n\t}\n\n\treturn n.diagnose(ns.Status.Phase)\n}\n\nfunc (Namespace) diagnose(phase v1.NamespacePhase) error {\n\tif phase != v1.NamespaceActive && phase != v1.NamespaceTerminating {\n\t\treturn errors.New(\"namespace not ready\")\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":97,"sourceCodeEnd":120,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/render/ns.go#L97-L120","documentation":"Returned by `Namespace.diagnose` (internal/render/ns.go) when a namespace's `status.phase` is neither `Active` nor `Terminating`. The Kubernetes API only defines those two phases, so any other value means the object is incomplete or not yet observed: typically an empty phase on a just-created namespace before the namespace controller sets it, or an object converted from an Unstructured payload that lacked `status.phase`. It surfaces in the VALID column of the namespace view via `AsStatus(n.diagnose(...))`.","triggerScenarios":"`runtime.DefaultUnstructuredConverter.FromUnstructured` succeeds but the resulting `v1.Namespace.Status.Phase` is \"\" (or any non-Active/Terminating value), so `diagnose` returns the error. Common with namespaces listed in the instant between creation and the controller writing status, or with fake/test clusters that never populate phase.","commonSituations":"Freshly created namespace viewed immediately (`kubectl create ns x` then list in k9s); watch caches served by a broken etcd/apiserver; CRD-backed or virtual clusters (vcluster, fake apiserver) that do not implement namespace lifecycle; stale cached objects after control-plane restart.","solutions":["Refresh the view (press 0 or wait for the watcher) — the namespace controller usually sets Active within seconds","Verify the real phase: `kubectl get ns <name> -o jsonpath='{.status.phase}'`","If the phase stays empty, inspect namespace controller health and apiserver/etcd logs","For fake/virtual clusters, populate status.phase or accept the VALID warning"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Only diagnose namespaces with a known phase:\nphase := ns.Status.Phase\nif phase == v1.NamespaceActive || phase == v1.NamespaceTerminating {\n    err = nsRenderer.diagnose(phase)\n}","typeGuard":"func nsPhaseReady(p v1.NamespacePhase) bool {\n    return p == v1.NamespaceActive || p == v1.NamespaceTerminating\n}","tryCatchPattern":"if err := diagnose(ns.Status.Phase); err != nil {\n    // requeue/refresh: phase not yet observed\n}","preventionTips":["Wait one controller sync after creating namespaces before asserting readiness","Populate status.phase in fake/test apiservers","Treat VALID warnings as observations, not failures"],"tags":["kubernetes","namespace","lifecycle","render","k9s"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}