{"record":{"id":"d40c4e793e4e152c","repo":"ahmetb/kubectx","slug":"kubeconfig-error-w-d40c4e","errorCode":null,"errorMessage":"kubeconfig error: %w","messagePattern":"kubeconfig error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubens/list.go","lineNumber":41,"sourceCode":"\t\"slices\"\n\n\tmetav1 \"k8s.io/apimachinery/pkg/apis/meta/v1\"\n\t\"k8s.io/client-go/kubernetes\"\n\t_ \"k8s.io/client-go/plugin/pkg/client/auth\"\n\t\"k8s.io/client-go/rest\"\n\t\"k8s.io/client-go/tools/clientcmd\"\n\n\t\"github.com/ahmetb/kubectx/internal/kubeconfig\"\n\t\"github.com/ahmetb/kubectx/internal/printer\"\n)\n\ntype ListOp struct{}\n\nfunc (op ListOp) Run(stdout, stderr io.Writer) error {\n\tkc := new(kubeconfig.Kubeconfig).WithLoader(kubeconfig.DefaultLoader)\n\tdefer kc.Close()\n\tif err := kc.Parse(); err != nil {\n\t\treturn fmt.Errorf(\"kubeconfig error: %w\", err)\n\t}\n\treturn formatNamespaceList(kc, stdout)\n}\n\n// formatNamespaceList writes the sorted, current-namespace-highlighted list\n// of namespaces available in the current context to w (one per line). It\n// mirrors what ListOp.Run prints so the interactive fzf picker shows the same\n// list the user would see from `kubens | fzf`.\nfunc formatNamespaceList(kc *kubeconfig.Kubeconfig, w io.Writer) error {\n\tctx, err := kc.GetCurrentContext()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get current context: %w\", err)\n\t}\n\tif ctx == \"\" {\n\t\treturn errors.New(\"current-context is not set\")\n\t}\n\tcurNs, err := kc.NamespaceOfContext(ctx)\n\tif err != nil {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubens/list.go#L23-L59","documentation":"Generic kubeconfig parse guard at the top of ListOp.Run: loading or decoding the kubeconfig files failed before namespaces could be listed. Wrapped error distinguishes unreadable files (load) from invalid YAML (decode).","triggerScenarios":"Thrown at cmd/kubens/list.go:41 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify KUBECONFIG file paths exist and are readable","Validate each file's YAML syntax","Repair or remove the broken file and rerun kubens"],"exampleFix":null,"handlingStrategy":"try-catch","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"}