{"record":{"id":"1b1c01f5d7f6b3d8","repo":"ahmetb/kubectx","slug":"kubeconfig-error-w-1b1c01","errorCode":null,"errorMessage":"kubeconfig error: %w","messagePattern":"kubeconfig error: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubectx/rename.go","lineNumber":52,"sourceCode":"func parseRenameSyntax(v string) (string, string, bool) {\n\tnew, old, ok := strings.Cut(v, \"=\")\n\tif !ok || new == \"\" || old == \"\" {\n\t\treturn \"\", \"\", false\n\t}\n\treturn new, old, true\n}\n\n// rename changes the old (NAME or '.' for current-context)\n// to the \"new\" value. If the old refers to the current-context,\n// current-context preference is also updated.\nfunc (op RenameOp) Run(_, 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\treturn fmt.Errorf(\"kubeconfig error: %w\", err)\n\t}\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\tif op.Old == \".\" {\n\t\top.Old = cur\n\t}\n\n\toldExists, err := kc.ContextExists(op.Old)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to check context: %w\", err)\n\t}\n\tif !oldExists {\n\t\treturn fmt.Errorf(\"context \\\"%s\\\" not found, can't rename it\", op.Old)\n\t}\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubectx/rename.go#L34-L70","documentation":"Wrapper error in RenameOp.Run: kc.Parse() failed to load/decode the kubeconfig before the rename could begin. The underlying cause (missing/invalid file, bad YAML) is wrapped with %w; the rename aborts.","triggerScenarios":"Thrown at cmd/kubectx/rename.go:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the kubeconfig per the wrapped cause (validate with `kubectl config view`)","Check KUBECONFIG env var and file permissions"],"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"}