gastownhall/beads · error
invalid format template: %w
Error message
invalid format template: %w
What it means
outputFormattedList parses the --format string as a Go text/template; this error wraps the template.Parse failure. It means the user-supplied format string has invalid template syntax. The underlying parse error (line/offset) is wrapped via %w.
Source
Thrown at cmd/bd/list_output.go:119
return outputDotFormat(out, issues, depsByIssueID)
}
w := &graphExportWriter{out: out}
// Built-in format presets
presets := map[string]string{
"digraph": "{{.IssueID}} {{.DependsOnID}}",
}
// Check if it's a preset
templateStr, isPreset := presets[formatStr]
if !isPreset {
templateStr = formatStr
}
// Parse template
tmpl, err := template.New("format").Parse(templateStr)
if err != nil {
return fmt.Errorf("invalid format template: %w", err)
}
// Build map of all issues for quick lookup
issueMap := make(map[string]bool)
for _, issue := range issues {
issueMap[issue.ID] = true
}
// 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,View on GitHub (pinned to 71377f2769)
Solutions
- Fix the template syntax per the wrapped parse error's line/column
- Use double quotes in your shell so braces aren't mangled: --format '{{.ID}} {{.Title}}'
- Check field names match Issue struct fields (e.g. {{.Issue.Title}} in dependency context)
- Test with a minimal template like '{{.ID}}' first
Example fix
// before
bd list --format '{{.ID'
// after
bd list --format '{{.ID}} {{.Title}}' Defensive patterns
Strategy: validation
Validate before calling
# Sanity-check braces balance before invoking
tpl='{{.ID}} {{.Title}}'
[[ $(grep -o '{{' <<<"$tpl" | wc -l) -eq $(grep -o '}}' <<<"$tpl" | wc -l) ]] || { echo "unbalanced template braces"; exit 2; }
bd list --format "$tpl" Try / catch
// Catch and surface the wrapped parse error (position info) out=$(bd list --format "$tpl" 2>&1) || case "$out" in *"invalid format template"*) echo "$out" >&2; exit 1;; esac
Prevention
- Start from a known-good template like '{{.ID}} {{.Title}}'
- Single-quote templates in shell to protect braces and %
- Keep Go text/template syntax docs handy; Go template != Jinja
When it happens
Trigger: `bd list --format '{{.ID'` or any --format value with unbalanced braces, bad actions, or invalid functions passed to template.New("format").Parse.
Common situations: Hand-written format strings with typos (`{{.id}` — wrong case or missing brace), shell interpolation mangling braces, copying templates from docs for other tools.
Related errors
- template execution error: %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/2e45c1dcee6f4f79.
Report an issue: GitHub.