{"record":{"id":"a5c33b0a96124cf7","repo":"grafana/k6","slug":"failed-to-encode-output-version-details-w","errorCode":null,"errorMessage":"failed to encode/output version details: %w","messagePattern":"failed to encode/output version details: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/version.go","lineNumber":233,"sourceCode":"\tgs     *state.GlobalState\n\tisJSON bool\n}\n\nfunc (c *versionCmd) run(cmd *cobra.Command, _ []string) error {\n\tif !c.isJSON {\n\t\troot := cmd.Root()\n\t\troot.SetArgs([]string{\"--version\"})\n\t\t_ = root.Execute()\n\t\treturn nil\n\t}\n\n\tdetails, err := versionDetailsWithExtensions(ext.GetAll())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get version details with extensions: %w\", err)\n\t}\n\n\tif err := json.NewEncoder(c.gs.Stdout).Encode(details); err != nil {\n\t\treturn fmt.Errorf(\"failed to encode/output version details: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc getCmdVersion(gs *state.GlobalState) *cobra.Command {\n\tversionCmd := &versionCmd{gs: gs}\n\n\tcmd := &cobra.Command{\n\t\tUse:    \"version\",\n\t\tShort:  \"Show application version\",\n\t\tLong:   `Show the application version and exit.`,\n\t\tHidden: true,\n\t\tRunE:   versionCmd.run,\n\t}\n\n\tcmd.Flags().BoolVar(&versionCmd.isJSON, \"json\", false, \"if set, output version information will be in JSON format\")\n","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cmd/version.go#L215-L251","documentation":"Wrapper around json.NewEncoder(...).Encode failing to write version details to stdout in 'k6 version --json'. Practically an I/O failure on the standard output stream, not a data problem.","triggerScenarios":"Thrown at internal/cmd/version.go:233 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure stdout is open and not a closed/full pipe","Avoid piping to commands that exit early and close the pipe"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}