{"record":{"id":"7fafb09e44bf60b9","repo":"ahmetb/kubectx","slug":"write-error-w","errorCode":null,"errorMessage":"write error: %w","messagePattern":"write error: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubectx/current.go","lineNumber":46,"sourceCode":"func (_op CurrentOp) Run(stdout, _ 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\tv, err := kc.GetCurrentContext()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get current context: %w\", err)\n\t}\n\tif v == \"\" {\n\t\treturn errors.New(\"current-context is not set\")\n\t}\n\tif _, err := fmt.Fprintln(stdout, v); err != nil {\n\t\treturn fmt.Errorf(\"write error: %w\", err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":28,"sourceCodeEnd":50,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubectx/current.go#L28-L50","documentation":"Wrapper error in CurrentOp.Run: fmt.Fprintln to stdout failed while printing the current context name (e.g. broken pipe when piped to a closed consumer like `kubectx -c | head`). The write error is wrapped with %w and returned.","triggerScenarios":"Thrown at cmd/kubectx/current.go:46 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the downstream consumer of the pipe is still running","Rerun without piping, or handle SIGPIPE in the calling script"],"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"}