{"record":{"id":"08ce3f3ef92ad539","repo":"ahmetb/kubectx","slug":"write-error-w-08ce3f","errorCode":null,"errorMessage":"write error: %w","messagePattern":"write error: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubectx/help.go","lineNumber":57,"sourceCode":"  %PROG% -s, --shell <NAME>    : start a shell scoped to context <NAME>\n  %PROG% -s, --shell           : interactively select a context to start a shell\n  %PROG% -r, --readonly <NAME> : start a read-only shell for context <NAME>\n  %PROG% -r, --readonly        : interactively select a context for read-only shell\n  %PROG% -c, --current         : show the current context name\n  %PROG% -u, --unset           : unset the current context\n  %PROG% <NEW_NAME>=<NAME>     : rename context <NAME> to <NEW_NAME>\n  %PROG% <NEW_NAME>=.          : rename current-context to <NEW_NAME>\n  %PROG% -d <NAME> [<NAME...>] : delete context <NAME> ('.' for current-context)\n  %SPAC%                         (this command won't delete the user/cluster entry\n  %SPAC%                          referenced by the context entry)\n  %PROG% -h, --help            : show this message\n  %PROG% -V, --version         : show version`\n\thelp = strings.ReplaceAll(help, \"%PROG%\", selfName())\n\thelp = strings.ReplaceAll(help, \"%SPAC%\", strings.Repeat(\" \", len(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\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 \"kubectx\"\n}\n","sourceCodeStart":39,"sourceCodeEnd":71,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubectx/help.go#L39-L71","documentation":"Wraps the error returned when writing the usage/help text to the output writer inside printUsage. It fires when the io.Writer passed by Run fails during the Fprintf of the usage template (e.g. a broken pipe, closed stdout, or write failure on the destination stream), not because of any problem with the help content itself.","triggerScenarios":"Thrown at cmd/kubectx/help.go:57 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure stdout is open and the downstream consumer (pipe/head) is alive","Rerun `kubectx --help` without piping to a short-lived consumer"],"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"}