{"record":{"id":"ebf63514ddf3d2a1","repo":"ahmetb/kubectx","slug":"write-error-w-ebf635","errorCode":null,"errorMessage":"write error: %w","messagePattern":"write error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubens/help.go","lineNumber":50,"sourceCode":"func printUsage(out io.Writer) error {\n\thelp := `Switch between Kubernetes namespaces.\n\nUSAGE:\n  %PROG%                    : list the namespaces in the current context\n  %PROG% <NAME>             : change the active namespace of current context\n  %PROG% <NAME> --force/-f  : force change the active namespace of current context (even if it doesn't exist)\n  %PROG% -                  : switch to the previous namespace in this context\n  %PROG% -c, --current      : show the current namespace\n  %PROG% -h,--help          : show this message\n  %PROG% -u,--unset         : unset the namespace choice (set to 'default')\n  %PROG% -V,--version       : show version`\n\n\t// TODO this replace logic is duplicated between this and kubectx\n\thelp = strings.ReplaceAll(help, \"%PROG%\", selfName())\n\n\t_, err := fmt.Fprintf(out, \"%s\\n\", help)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"write error: %w\", err)\n\t}\n\treturn nil\n}\n\n// selfName guesses how the user invoked the program.\nfunc selfName() string {\n\t// TODO this method is duplicated between this and kubectx\n\tme := filepath.Base(os.Args[0])\n\tpluginPrefix := \"kubectl-\"\n\tif strings.HasPrefix(me, pluginPrefix) {\n\t\treturn \"kubectl \" + strings.TrimPrefix(me, pluginPrefix)\n\t}\n\treturn \"kubens\"\n}\n","sourceCodeStart":32,"sourceCodeEnd":65,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubens/help.go#L32-L65","documentation":"Wraps the error from writing the kubens usage/help text to the output writer inside printUsage. It fires when the io.Writer provided by Run fails while emitting the help template (broken pipe, closed/unwritable stdout), and is unrelated to the content or validity of the usage text.","triggerScenarios":"Thrown at cmd/kubens/help.go:50 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure stdout/stderr is not closed when invoking kubens --help","If piping help output (e.g. kubens -h | head), the pipe may close early; this is usually harmless"],"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"}