gastownhall/beads · error
failed to get template: %w
Error message
failed to get template: %w
What it means
After a store is available, loadTemplateSubgraph fetches the root issue for the template ID via s.GetIssue. If that lookup fails (storage error, connectivity, corruption), the failure is wrapped with this message. It is distinct from 'template not found': the database call itself errored.
Source
Thrown at cmd/bd/template.go:91
}
// bondedIDPattern validates bonded IDs (alphanumeric, dash, underscore, dot)
var bondedIDPattern = regexp.MustCompile(`^[a-zA-Z0-9_.-]+$`)
// =============================================================================
// Beads Template Functions
// =============================================================================
// loadTemplateSubgraph loads a template epic and all its descendants
func loadTemplateSubgraph(ctx context.Context, s molReader, templateID string) (*TemplateSubgraph, error) {
if s == nil {
return nil, fmt.Errorf("no database connection")
}
// Get the root issue
root, err := s.GetIssue(ctx, templateID)
if err != nil {
return nil, fmt.Errorf("failed to get template: %w", err)
}
if root == nil {
return nil, fmt.Errorf("template %s not found", templateID)
}
subgraph := &TemplateSubgraph{
Root: root,
Issues: []*types.Issue{root},
IssueMap: map[string]*types.Issue{root.ID: root},
}
// Recursively load all children (with cycle detection, GH#2719)
visited := map[string]bool{root.ID: true}
if err := loadDescendants(ctx, s, subgraph, root.ID, visited); err != nil {
return nil, err
}
// Load all dependencies within the subgraphView on GitHub (pinned to 71377f2769)
Solutions
- Retry the command — the wrapped cause often indicates a transient storage error
- Verify the Dolt server/database is healthy (bd doctor; check server logs)
- Confirm the store connection settings and that the database is not locked or corrupted
- Inspect the wrapped inner error after this message for the exact GetIssue failure
Example fix
// before (no retry in script) bd cook my-template // after for i in 1 2 3; do bd cook my-template && break; sleep 2; done
Defensive patterns
Strategy: retry
Validate before calling
bd doctor > /dev/null || { echo "database unhealthy; fix before template ops" >&2; exit 1; }
bd list --json > /dev/null || { echo "cannot read database" >&2; exit 1; } Try / catch
sub, err := loadTemplateSubgraph(ctx, store, tplID)
if err != nil {
var retriable = strings.Contains(err.Error(), "failed to get template")
if retriable && attempts < 3 {
time.Sleep(backoff); continue
}
return fmt.Errorf("template lookup failed: %w", err)
} Prevention
- Retry transient storage failures with backoff in scripts
- Keep the Dolt server supervised so connections don't die mid-command
- Check the wrapped inner error to distinguish connectivity issues from data problems
When it happens
Trigger: Any template operation (delete/bond/attach/cook/burn flows) where s.GetIssue(ctx, templateID) returns a non-nil error while loading the template epic — e.g. Dolt connection dropped mid-command, query timeout, or underlying storage failure.
Common situations: Dolt server restarted or connection timed out during a long-running template command; transient network errors in server mode; database file issues in embedded mode.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- ErrExec
- database not available: %w
- search gates: %w
- database not available: %w
- db: SetLocalMetadata %s: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/f71c7c8668318c62.
Report an issue: GitHub.