{"record":{"id":"00442594d88aa6b1","repo":"gastownhall/beads","slug":"template-execution-error-w","errorCode":null,"errorMessage":"template execution error: %w","messagePattern":"template execution error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/list_output.go","lineNumber":144,"sourceCode":"\t}\n\n\t// For each issue, output its dependencies using the template\n\tfor _, issue := range issues {\n\t\tfor _, dep := range depsByIssueID[issue.ID] {\n\t\t\t// Only output edges where both nodes are in the filtered list\n\t\t\tif issueMap[dep.DependsOnID] {\n\t\t\t\t// Template data includes both issue and dependency info\n\t\t\t\tdata := map[string]interface{}{\n\t\t\t\t\t\"IssueID\":     issue.ID,\n\t\t\t\t\t\"DependsOnID\": dep.DependsOnID,\n\t\t\t\t\t\"Type\":        dep.Type,\n\t\t\t\t\t\"Issue\":       issue,\n\t\t\t\t\t\"Dependency\":  dep,\n\t\t\t\t}\n\n\t\t\t\tvar buf bytes.Buffer\n\t\t\t\tif err := tmpl.Execute(&buf, data); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"template execution error: %w\", err)\n\t\t\t\t}\n\t\t\t\tw.println(buf.String())\n\t\t\t\tif err := w.wrapError(\"formatted list\"); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn w.wrapError(\"formatted list\")\n}\n","sourceCodeStart":126,"sourceCodeEnd":156,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/list_output.go#L126-L156","documentation":"During `bd list --format` rendering, executing the parsed template against each issue's data map failed. Unlike parse errors, this happens per-record at render time — e.g. calling a function with wrong argument types or on a nil field. Output is buffered per issue, so a failure aborts before writing partial rows.","triggerScenarios":"A --format template that parses but fails at Execute — e.g. {{.Title | printf \"%d\"}} (type mismatch), calling an undefined method on Issue, or nil dereference on missing fields.","commonSituations":"Format strings using wrong field types (formatting a string as int), templates assuming fields exist on every issue, or copy-pasted templates referencing unavailable data keys (Issue/Dependency map keys).","solutions":["Read the wrapped template error for the failing field/operation","Cast or format correctly: {{printf \"%s\" .Title}} not {{printf \"%d\" .Title}}","Reference available map keys only: .Issue and .Dependency","Simplify to plain field access ({{.ID}} {{.Status}}) and add functions back incrementally"],"exampleFix":"// before\n--format '{{printf \"%d\" .ID}}'\n// after\n--format '{{printf \"%s\" .ID}}'","handlingStrategy":"validation","validationCode":"// Validate field types before formatting: .ID is a string\n// Bad:  --format '{{printf \"%d\" .ID}}'\n// Good: --format '{{printf \"%s\" .ID}}'\nbd list --format '{{printf \"%s\" .ID}}' --limit 1 >/dev/null || echo \"template fails at execution\"","typeGuard":null,"tryCatchPattern":"// Test the template on one record before a full run\nif ! bd list --format \"$tpl\" --limit 1 >/dev/null 2>&1; then\n  bd list --format \"$tpl\" --limit 1 # show the template execution error\nfi","preventionTips":["Test --format with --limit 1 first","Match printf verbs to field types (%s for IDs/titles)","Only reference the exposed data keys (.Issue, .Dependency)"],"tags":["template","cli","formatting"],"backgroundTag":"template-execution-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}