{"record":{"id":"9199c36247b9f89d","repo":"matryer/xbar","slug":"parse-stdout","errorCode":null,"errorMessage":"parse stdout","messagePattern":"parse stdout","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plugins/plugin.go","lineNumber":327,"sourceCode":"\tvar stdout, stderr bytes.Buffer\n\tcmd.Stdout = &stdout\n\tcmd.Stderr = &stderr\n\tif p.Stdout != nil {\n\t\tcmd.Stdout = io.MultiWriter(cmd.Stdout, p.Stdout)\n\t}\n\tif p.Stderr != nil {\n\t\tcmd.Stderr = io.MultiWriter(cmd.Stderr, p.Stderr)\n\t}\n\tif err := cmd.Run(); err != nil {\n\t\treturn errExec{\n\t\t\terr:    err,\n\t\t\tStderr: stderr.String(),\n\t\t}\n\t}\n\tvar err error\n\tp.Items, err = p.parseOutput(ctx, filepath.Base(p.Command), &stdout)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"parse stdout\")\n\t}\n\treturn nil\n}\n\n// OnErr is called when something has gone wrong at some point.\nfunc (p *Plugin) OnErr(err error) {\n\tp.Items.CycleItems = []*Item{\n\t\t{\n\t\t\tPlugin: p,\n\t\t\tText:   \"⚠️ \" + p.CleanFilename(),\n\t\t},\n\t}\n\tp.Items.ExpandedItems = p.stringToItems(err.Error())\n}\n\n// errExec is used for plugin execution errors.\ntype errExec struct {\n\t// Stderr is the data captured from stderr.","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/plugin.go#L309-L345","documentation":"Plugin.refresh runs the plugin command and then parses its stdout into menu items via parseOutput. If parsing fails, the error is wrapped as 'parse stdout'. This is the central pipeline error: any output-format mistake made by a plugin surfaces here.","triggerScenarios":"parseOutput returns an error for the plugin's stdout — malformed item lines that trip the parser (e.g. errors detected during item parsing), or an underlying read failure (see 'reading').","commonSituations":"Plugin prints malformed parameter blocks (bad color/int values), emits invalid UTF-8 or oversized output, or its output format doesn't match what the parser expects after a library version update.","solutions":["Check the wrapped inner error (errors.Cause) for the specific parsing failure","Run the plugin script manually and inspect its stdout for malformed lines","Fix the offending parameter value (color, int, template) in the plugin script","Ensure output is valid UTF-8 and lines are well-formed 'Item | key=value' entries"],"exampleFix":"// before\necho \"Item | color=blurple\"    // invalid named color -> parse fails\n// after\necho \"Item | color=purple\"     // valid named color","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := plugin.Refresh(ctx); err != nil {\n    log.Printf(\"refresh failed: %v (cause: %v)\", err, errors.Unwrap(err))\n    plugin.SetItems(lastGoodItems) // keep previous menu\n}","preventionTips":["Test plugin stdout manually before deploying: ./plugin.sh | cat","Keep parameter values well-formed (valid colors, ints)","Pin library-compatible output format when upgrading","Cache last-good items to survive refresh failures"],"tags":["plugins","stdout","parsing","refresh"],"backgroundTag":"plugin-output-parse-failed","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}