{"record":{"id":"e98563d969e4823a","repo":"gastownhall/beads","slug":"template-s-not-found","errorCode":null,"errorMessage":"template %s not found","messagePattern":"template (.+?) not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/template.go","lineNumber":94,"sourceCode":"var bondedIDPattern = regexp.MustCompile(`^[a-zA-Z0-9_.-]+$`)\n\n// =============================================================================\n// Beads Template Functions\n// =============================================================================\n\n// loadTemplateSubgraph loads a template epic and all its descendants\nfunc loadTemplateSubgraph(ctx context.Context, s molReader, templateID string) (*TemplateSubgraph, error) {\n\tif s == nil {\n\t\treturn nil, fmt.Errorf(\"no database connection\")\n\t}\n\n\t// Get the root issue\n\troot, err := s.GetIssue(ctx, templateID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get template: %w\", err)\n\t}\n\tif root == nil {\n\t\treturn nil, fmt.Errorf(\"template %s not found\", templateID)\n\t}\n\n\tsubgraph := &TemplateSubgraph{\n\t\tRoot:     root,\n\t\tIssues:   []*types.Issue{root},\n\t\tIssueMap: map[string]*types.Issue{root.ID: root},\n\t}\n\n\t// Recursively load all children (with cycle detection, GH#2719)\n\tvisited := map[string]bool{root.ID: true}\n\tif err := loadDescendants(ctx, s, subgraph, root.ID, visited); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Load all dependencies within the subgraph\n\tfor _, issue := range subgraph.Issues {\n\t\tdeps, err := s.GetDependencyRecords(ctx, issue.ID)\n\t\tif err != nil {","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/template.go#L76-L112","documentation":"loadTemplateSubgraph loads a template root issue and its dependency subgraph. It first fetches the root issue by ID via s.GetIssue; if the storage layer returns nil issue with no error (i.e. the ID simply does not exist), it throws 'template %s not found'. This distinguishes a missing template from a storage failure, which would surface as 'failed to get template: %w' instead.","triggerScenarios":"Calling any proto-molecule operation (deleteProtoSubgraph, bondProtoMolWithSubgraph, bondProtoMolAttachInto, resolveOrCookToSubgraph, burnMultipleMolecules, burnWispMolecule) with a template ID that does not exist in the database — e.g. a typo'd ID, an ID from another repo/database, or a template that was already deleted.","commonSituations":"Running `bd mol pour <name>` or burn/delete commands after the proto was deleted or renamed; referencing a template ID copied from documentation of a different project; stale shell history after switching databases (different .beads directory).","solutions":["Run `bd list` or search protos (issues labeled with the template label) to find the correct template ID and retry with the exact ID.","If you only know the title, use the resolution path (resolveProtoIDOrTitle) which also matches by title.","Check you are operating in the correct repository/database (.beads directory) that actually contains the template.","If the template was deleted intentionally, recreate it before retrying the operation."],"exampleFix":"// before\nsub, err := instantiateFromTemplate(ctx, s, \"bd-wrong-id\", vars)\n// after\nid, err := resolveProtoIDOrTitle(ctx, s, \"my-proto-title\") // resolve first\nif err != nil { return err }\nsub, err := instantiateFromTemplate(ctx, s, id, vars)","handlingStrategy":"validation","validationCode":"root, err := s.GetIssue(ctx, templateID)\nif err != nil { return err }\nif root == nil { return fmt.Errorf(\"template %q does not exist; list protos first\", templateID) }","typeGuard":"func templateExists(ctx context.Context, s storage.DoltStorage, id string) bool {\n\tiss, err := s.GetIssue(ctx, id)\n\treturn err == nil && iss != nil\n}","tryCatchPattern":"sub, err := loadTemplateSubgraph(ctx, s, id)\nif err != nil {\n\tif strings.Contains(err.Error(), \"not found\") {\n\t\t// prompt user to pick from available protos\n\t}\n\treturn err\n}","preventionTips":["Resolve protos by title (resolveProtoIDOrTitle) instead of hardcoding IDs.","Confirm the template exists with a list/search command before operating on it.","Verify you are in the repository that owns the template."],"tags":["template","not-found","storage","cli"],"backgroundTag":"template-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}