{"record":{"id":"d9589244a75a2f2f","repo":"ahmetb/kubectx","slug":"failed-to-get-current-context-w-d95892","errorCode":null,"errorMessage":"failed to get current context: %w","messagePattern":"failed to get current context: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubectx/list.go","lineNumber":60,"sourceCode":"\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)\n\t}\n\tfor _, c := range ctxs {\n\t\ts := c\n\t\tif c == cur {\n\t\t\ts = printer.ActiveItemColor.Sprint(c)\n\t\t}\n\t\tfmt.Fprintf(w, \"%s\\n\", s)\n\t}\n\treturn nil\n}\n","sourceCodeStart":42,"sourceCodeEnd":71,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubectx/list.go#L42-L71","documentation":"Wrapper error in formatContextList: kc.GetCurrentContext() failed while reading current-context, needed to highlight the active entry in the list. The wrapped cause (via %w) carries the underlying kyaml/YAML failure; listing aborts.","triggerScenarios":"Thrown at cmd/kubectx/list.go:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped cause — usually malformed current-context data","Validate the kubeconfig with `kubectl config view` and repair"],"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"}