{"record":{"id":"e6622e10b1955339","repo":"ahmetb/kubectx","slug":"no-namespaces-found","errorCode":null,"errorMessage":"no namespaces found","messagePattern":"no namespaces found","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubens/fzf.go","lineNumber":52,"sourceCode":"// TODO(ahmetb) This method is heavily repetitive vs kubectx/fzf.go.\nfunc (op InteractiveSwitchOp) Run(_, stderr io.Writer) error {\n\t// parse kubeconfig just to see if it can be loaded\n\tkc := new(kubeconfig.Kubeconfig).WithLoader(kubeconfig.DefaultLoader)\n\tdefer kc.Close()\n\tif err := kc.Parse(); err != nil {\n\t\tif cmdutil.IsNotFoundErr(err) {\n\t\t\tprinter.Warning(stderr, \"kubeconfig file not found\")\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"kubeconfig error: %w\", err)\n\t}\n\n\tvar in bytes.Buffer\n\tif err := formatNamespaceList(kc, &in); err != nil {\n\t\treturn err\n\t}\n\tif in.Len() == 0 {\n\t\treturn errors.New(\"no namespaces found\")\n\t}\n\n\tcmd := exec.Command(\"fzf\", \"--ansi\", \"--no-preview\")\n\tvar out bytes.Buffer\n\tcmd.Stdin = &in\n\tcmd.Stderr = stderr\n\tcmd.Stdout = &out\n\n\tcmd.Env = append(os.Environ(),\n\t\tfmt.Sprintf(\"%s=1\", env.EnvForceColor))\n\tif err := cmd.Run(); err != nil {\n\t\tvar exitErr *exec.ExitError\n\t\tif !errors.As(err, &exitErr) {\n\t\t\treturn err\n\t\t}\n\t}\n\tchoice := strings.TrimSpace(out.String())\n\tif choice == \"\" {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubens/fzf.go#L34-L70","documentation":"Guard error in InteractiveSwitchOp.Run (kubens): formatNamespaceList produced an empty buffer, meaning the current context yields no namespaces to show. The fzf picker would be empty, so the interactive namespace switch aborts with this sentinel error.","triggerScenarios":"Thrown at cmd/kubens/fzf.go:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the cluster is reachable so namespaces can be listed (`kubectl get ns`)","Switch to a valid context with `kubectx <NAME>` first"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"12ad6fb22e8c546ee2b54e7de38aa51c906832f7","analyzedAt":"2026-09-02T12:23:10.107Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}