{"record":{"id":"f7ada0d7a89f264b","repo":"ahmetb/kubectx","slug":"failed-to-get-context-names-w-f7ada0","errorCode":null,"errorMessage":"failed to get context names: %w","messagePattern":"failed to get context names: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubectx/shell_session.go","lineNumber":135,"sourceCode":"// fzfPickContext launches fzf for interactive context selection.\nfunc fzfPickContext(stderr io.Writer) (string, error) {\n\tif err := checkIsolatedMode(); err != nil {\n\t\treturn \"\", err\n\t}\n\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\tctxNames, err := kc.ContextNames()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get context names: %w\", err)\n\t}\n\tif len(ctxNames) == 0 {\n\t\treturn \"\", errors.New(\"no contexts found in the kubeconfig file\")\n\t}\n\n\tvar in bytes.Buffer\n\tif err := formatContextList(kc, &in); err != nil {\n\t\treturn \"\", err\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))","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubectx/shell_session.go#L117-L153","documentation":"ContextNames() errored while enumerating context names to feed the fzf interactive picker. Fires when the kyaml read of the contexts list fails in one of the kubeconfig files; note the not-found-file case is handled separately above, so this is a structural/read error.","triggerScenarios":"Thrown at cmd/kubectx/shell_session.go:135 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the YAML of each file in KUBECONFIG, especially the contexts list","Remove or fix the file that fails to parse (kubectl config get-contexts can help find it)","Retry the fzf picker after 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"}