{"record":{"id":"f8a1a009f9d0acc2","repo":"ahmetb/kubectx","slug":"kubeconfig-error-w-f8a1a0","errorCode":null,"errorMessage":"kubeconfig error: %w","messagePattern":"kubeconfig error: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubectx/list.go","lineNumber":42,"sourceCode":"\t\"github.com/ahmetb/kubectx/internal/kubeconfig\"\n\t\"github.com/ahmetb/kubectx/internal/printer\"\n)\n\n// ListOp describes listing contexts.\ntype ListOp struct{}\n\nfunc (_ ListOp) Run(stdout, stderr io.Writer) error {\n\tif err := checkIsolatedMode(); err != nil {\n\t\treturn err\n\t}\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\treturn formatContextList(kc, stdout)\n}\n\n// formatContextList writes the sorted, current-context-highlighted list of\n// contexts from kc to w (one per line). The format mirrors what ListOp.Run\n// prints so that the interactive fzf picker shows the same list the user would\n// see from `kubectx | fzf`.\nfunc formatContextList(kc *kubeconfig.Kubeconfig, w io.Writer) error {\n\tctxs, err := kc.ContextNames()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get context names: %w\", err)\n\t}\n\tnatsort.Sort(ctxs)\n\n\tcur, err := kc.GetCurrentContext()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get current context: %w\", err)","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubectx/list.go#L24-L60","documentation":"Wrapper error in ListOp.Run: kc.Parse() failed with an error other than 'kubeconfig file not found' (which is downgraded to a warning), meaning a real load/decode failure — bad YAML, permissions, or an invalid file among those in KUBECONFIG. Wrapped with %w; the context list aborts.","triggerScenarios":"Thrown at cmd/kubectx/list.go:42 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the wrapped cause; typically fix malformed YAML or file permissions","Test with `kubectl config view` to isolate the bad file in KUBECONFIG"],"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"}