gastownhall/beads · error
template execution error: %w
Error message
template execution error: %w
What it means
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.
Source
Thrown at cmd/bd/list_output.go:144
}
// For each issue, output its dependencies using the template
for _, issue := range issues {
for _, dep := range depsByIssueID[issue.ID] {
// Only output edges where both nodes are in the filtered list
if issueMap[dep.DependsOnID] {
// Template data includes both issue and dependency info
data := map[string]interface{}{
"IssueID": issue.ID,
"DependsOnID": dep.DependsOnID,
"Type": dep.Type,
"Issue": issue,
"Dependency": dep,
}
var buf bytes.Buffer
if err := tmpl.Execute(&buf, data); err != nil {
return fmt.Errorf("template execution error: %w", err)
}
w.println(buf.String())
if err := w.wrapError("formatted list"); err != nil {
return err
}
}
}
}
return w.wrapError("formatted list")
}
View on GitHub (pinned to 71377f2769)
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
Example fix
// before
--format '{{printf "%d" .ID}}'
// after
--format '{{printf "%s" .ID}}' Defensive patterns
Strategy: validation
Validate before calling
// Validate field types before formatting: .ID is a string
// Bad: --format '{{printf "%d" .ID}}'
// Good: --format '{{printf "%s" .ID}}'
bd list --format '{{printf "%s" .ID}}' --limit 1 >/dev/null || echo "template fails at execution" Try / catch
// Test the template on one record before a full run if ! bd list --format "$tpl" --limit 1 >/dev/null 2>&1; then bd list --format "$tpl" --limit 1 # show the template execution error fi
Prevention
- Test --format with --limit 1 first
- Match printf verbs to field types (%s for IDs/titles)
- Only reference the exposed data keys (.Issue, .Dependency)
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- invalid format template: %w
- template %s not found
- no proto found matching %q (by ID or title)
- ambiguous: %q matches %d protos: %s Use the ID or a more s
- ErrAmbiguousID
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/00442594d88aa6b1.
Report an issue: GitHub.