{"record":{"id":"1c9e6d56201b4cd0","repo":"gastownhall/beads","slug":"writing-s-output-w","errorCode":null,"errorMessage":"writing %s output: %w","messagePattern":"writing (.+?) output: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/graph_export.go","lineNumber":94,"sourceCode":"func (w *graphExportWriter) printf(format string, args ...interface{}) {\n\tif w.err != nil {\n\t\treturn\n\t}\n\t_, w.err = fmt.Fprintf(w.out, format, args...)\n}\n\nfunc (w *graphExportWriter) println(args ...interface{}) {\n\tif w.err != nil {\n\t\treturn\n\t}\n\t_, w.err = fmt.Fprintln(w.out, args...)\n}\n\nfunc (w *graphExportWriter) wrapError(kind string) error {\n\tif w.err == nil {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"writing %s output: %w\", kind, w.err)\n}\n\n// dotNodeAttrs returns the DOT label, fill color, and font color for a node\nfunc dotNodeAttrs(node *GraphNode) (label, fillColor, fontColor string) {\n\ticon := statusPlainIcon(node.Issue.Status)\n\ttitle := truncateTitle(node.Issue.Title, 40)\n\tlabel = fmt.Sprintf(\"%s %s\\\\nP%d | %s\", icon, node.Issue.ID, node.Issue.Priority, title)\n\n\tswitch node.Issue.Status {\n\tcase types.StatusOpen:\n\t\tfillColor = \"#e8f4fd\"\n\t\tfontColor = \"#1a1a1a\"\n\tcase types.StatusInProgress:\n\t\tfillColor = \"#fff3cd\"\n\t\tfontColor = \"#664d03\"\n\tcase types.StatusBlocked:\n\t\tfillColor = \"#f8d7da\"\n\t\tfontColor = \"#842029\"","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/graph_export.go#L76-L112","documentation":"Wraps the io.Writer error accumulated by graphExportWriter when emitting `bd graph` output of a given kind (jsonl, dot, list, etc.). The underlying write failed — usually a closed/broken stdout, full disk, or closed pipe.","triggerScenarios":"Running bd graph ... > file on a full disk; piping into `head` which closes the pipe (SIGPIPE/EPIPE); redirecting to an unwritable file.","commonSituations":"CI logs to a full tmpfs; `bd graph | head -5` causing broken pipe; read-only output file.","solutions":["Check disk space and write permissions on the output target","Avoid closing the pipe early (don't pipe into head/less -quit), or ignore EPIPE deliberately","Redirect to a different writable location"],"exampleFix":"// before\nbd graph --format dot | head -5\n// after\nbd graph --format dot > graph.dot && less graph.dot","handlingStrategy":"try-catch","validationCode":"f, err := os.OpenFile(outPath, os.O_WRONLY|os.O_CREATE, 0o644)\nif err != nil { return err }\nif _, err := f.WriteString(\"probe\"); err != nil { return fmt.Errorf(\"output not writable: %w\", err) }\nf.Close()","typeGuard":null,"tryCatchPattern":"if err := bd.Graph(...); err != nil {\n  var pe *os.PathError\n  if errors.As(err, &pe) && errors.Is(pe.Err, syscall.EPIPE) {\n    return nil // consumer closed the pipe; benign\n  }\n  return err\n}","preventionTips":["Check free disk space before large graph exports","Don't pipe into commands that exit early (head); use a file instead","Verify write permission on the redirect target"],"tags":["go","io","broken-pipe","graph-export"],"backgroundTag":"write-failed-broken-pipe","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}