{"record":{"id":"925e34d7cb65b8b5","repo":"slimtoolkit/slim","slug":"no-namespaces","errorCode":null,"errorMessage":"no namespaces","messagePattern":"no namespaces","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/command/debug/handle_kubernetes_runtime.go","lineNumber":636,"sourceCode":"\n\tnames, err := listNamespaces(ctx, api)\n\tif err != nil {\n\t\tlog.WithError(err).Error(\"listNamespaces\")\n\t\treturn nil, err\n\t}\n\n\treturn names, nil\n}\n\nfunc ensureNamespace(ctx context.Context, api *kubernetes.Clientset, name string) (string, error) {\n\tif name == \"\" {\n\t\tnamespaces, err := api.CoreV1().Namespaces().List(ctx, metav1.ListOptions{})\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tif len(namespaces.Items) == 0 {\n\t\t\treturn \"\", fmt.Errorf(\"no namespaces\")\n\t\t}\n\n\t\treturn namespaces.Items[0].Name, nil\n\t}\n\n\t_, err := api.CoreV1().Namespaces().Get(ctx, name, metav1.GetOptions{})\n\tif err != nil {\n\t\tif apierrors.IsNotFound(err) {\n\t\t\tlog.Debugf(\"ensureNamespace: %s namespace is not found\", name)\n\t\t}\n\n\t\treturn \"\", err\n\t}\n\n\treturn name, nil\n}\n\nfunc listActivePods(ctx context.Context, api *kubernetes.Clientset, nsName string) ([]string, error) {","sourceCodeStart":618,"sourceCodeEnd":654,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/command/debug/handle_kubernetes_runtime.go#L618-L654","documentation":"ensureNamespace resolves the namespace to operate in. When no explicit namespace is given, it falls back to listing all namespaces and using the first one; if the cluster API reports zero namespaces, it fails with 'no namespaces'. An empty namespace list means the API connection is not seeing any cluster content.","triggerScenarios":"HandleKubernetesRuntime -> ensureNamespace with no namespace name configured; CoreV1().Namespaces().List returns success but an empty Items slice.","commonSituations":"KUBECONFIG pointing at the wrong cluster or a local mock/proxy that returns empty lists; connecting to a cluster endpoint with a context that has no permissions so list results are filtered to zero; kubeconfig default context changed (e.g., after switching from kind/minikube to a fresh cluster).","solutions":["Pass an explicit namespace to the command so the List fallback is skipped.","Check `kubectl config current-context` and `kubectl get namespaces` to confirm you are on the intended cluster and can list namespaces.","Fix KUBECONFIG (points to wrong cluster/empty control plane) and retry.","Verify RBAC allows listing namespaces; with restrictive RBAC the list may come back empty."],"exampleFix":"// before: relies on auto-detected namespace\nslim debug <target>\n// after\nslim debug <target> --namespace default","handlingStrategy":"validation","validationCode":"ctx=$(kubectl config current-context)\n[ \"$(kubectl get namespaces -o name | wc -l)\" -gt 0 ] || echo \"context $ctx sees no namespaces — check kubeconfig\"","typeGuard":null,"tryCatchPattern":"if err := runDebug(target); err != nil && strings.Contains(err.Error(), \"no namespaces\") {\n    // prompt user to set KUBECONFIG / --namespace\n}","preventionTips":["Always pass --namespace explicitly","Pin KUBECONFIG in scripts (don't rely on default context)","Verify context with kubectl before running tooling"],"tags":["kubernetes","namespace","kubeconfig"],"backgroundTag":"no-namespaces-found","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}