{"record":{"id":"46e58f8b3e12601c","repo":"gastownhall/beads","slug":"writing-html-output-w","errorCode":null,"errorMessage":"writing HTML output: %w","messagePattern":"writing HTML output: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/graph_export.go","lineNumber":180,"sourceCode":"\tnodes := buildHTMLGraphData(layout, subgraph)\n\tedges := buildHTMLEdgeData(layout, subgraph)\n\n\tnodesJSON, err := json.Marshal(nodes)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"marshaling HTML graph nodes: %w\", err)\n\t}\n\tedgesJSON, err := json.Marshal(edges)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"marshaling HTML graph edges: %w\", err)\n\t}\n\n\ttitle := \"Beads Dependency Graph\"\n\tif subgraph.Root != nil {\n\t\ttitle = fmt.Sprintf(\"Beads: %s (%s)\", subgraph.Root.Title, subgraph.Root.ID)\n\t}\n\n\tif _, err := fmt.Fprintf(out, htmlTemplate, html.EscapeString(title), string(nodesJSON), string(edgesJSON)); err != nil {\n\t\treturn fmt.Errorf(\"writing HTML output: %w\", err)\n\t}\n\treturn nil\n}\n\n// HTMLNode is the JSON structure for a node in the HTML visualization\ntype HTMLNode struct {\n\tID       string `json:\"id\"`\n\tTitle    string `json:\"title\"`\n\tStatus   string `json:\"status\"`\n\tPriority int    `json:\"priority\"`\n\tType     string `json:\"type\"`\n\tLayer    int    `json:\"layer\"`\n\tAssignee string `json:\"assignee,omitempty\"`\n}\n\n// HTMLEdge is the JSON structure for an edge in the HTML visualization\ntype HTMLEdge struct {\n\tSource string `json:\"source\"`","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/graph_export.go#L162-L198","documentation":"The formatted Fprintf of the HTML template (title, nodes JSON, edges JSON) to the output writer failed. The marshal step succeeded; the actual write to stdout/file errored — typically broken pipe, full disk, or closed writer.","triggerScenarios":"bd graph --format html piped into a command that exits early (head), redirecting to a full filesystem, or writing to an already-closed writer in tests/embedded use.","commonSituations":"CI piping HTML output into head; disk quota exceeded; tests passing a closed buffer.","solutions":["Check the wrapped io error (EPIPE vs ENOSPC vs permission)","Free disk space or redirect to a writable target","Don't close the consuming pipe prematurely"],"exampleFix":"// before\nbd graph --format html | head -1\n// after\nbd graph --format html > graph.html","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := bd.Graph(ctx, \"html\"); err != nil {\n  if strings.Contains(err.Error(), \"writing HTML output\") {\n    // check underlying cause\n    log.Printf(\"html write failed: %v\", err)\n    // fall back to writing to a temp file\n  }\n  return err\n}","preventionTips":["Write HTML output to a file, not a short-lived pipe","Ensure adequate disk space for full HTML pages","In embedded use, keep the io.Writer open until after Graph returns"],"tags":["go","io","html","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"}