{"record":{"id":"b2108f44a8413a60","repo":"gastownhall/beads","slug":"querying-epics-w","errorCode":null,"errorMessage":"querying epics: %w","messagePattern":"querying epics: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/mol_stale.go","lineNumber":136,"sourceCode":"\t\t\t\tui.RenderID(mol.ID), mol.Title, progress)\n\t\t\tfmt.Printf(\"       → Close with: bd close %s\\n\", mol.ID)\n\t\t}\n\t\tfmt.Println()\n\t}\n\n\tfmt.Printf(\"Total: %d stale\", result.TotalCount)\n\tif result.BlockingCount > 0 {\n\t\tfmt.Printf(\", %d blocking other work\", result.BlockingCount)\n\t}\n\tfmt.Println()\n}\n\n// findStaleMolecules queries the database for stale molecules\nfunc findStaleMolecules(ctx context.Context, s molReader, blockingOnly, unassignedOnly, showAll bool) (*StaleResult, error) {\n\t// Get all epics eligible for closure (complete but unclosed)\n\tepicStatuses, err := s.GetEpicsEligibleForClosure(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"querying epics: %w\", err)\n\t}\n\n\t// Get blocked issues to find what each stale molecule is blocking\n\tblockedIssues, err := s.GetBlockedIssues(ctx, types.WorkFilter{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"querying blocked issues: %w\", err)\n\t}\n\n\t// Build map of issue ID -> what issues it's blocking\n\tblockingMap := buildBlockingMap(blockedIssues)\n\n\tvar staleMolecules []*StaleMolecule\n\tblockingCount := 0\n\n\tfor _, es := range epicStatuses {\n\t\t// Skip if not eligible for close (not all children closed)\n\t\tif !es.EligibleForClose {\n\t\t\tcontinue","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/mol_stale.go#L118-L154","documentation":"findStaleMolecules first queries all epics eligible for closure via GetEpicsEligibleForClosure. A failure there is wrapped as 'querying epics: %w', so bd mol stale cannot enumerate stale molecule candidates.","triggerScenarios":"bd mol stale when the epic-closure query fails: database unavailable, epic eligibility query error, proxied server returning an error, or schema mismatch.","commonSituations":"Dolt server down in proxied mode; corrupt or partially-migrated database; interrupted sync leaving inconsistent epic/dependency rows.","solutions":["Check the wrapped cause and fix the underlying storage/server error first","Run bd doctor to validate database integrity and schema version","If proxied, confirm the daemon is reachable and retry","Retry bd stale once the query layer is healthy"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Health-check storage before stale scan\nif err := s.GetBlockedIssues(ctx, types.WorkFilter{Limit: 1}); err != nil {\n    return fmt.Errorf(\"storage unavailable: %w\", err)\n}","typeGuard":"func storageOK(s molReader) bool { return s != nil }","tryCatchPattern":"res, err := findStaleMolecules(ctx, s, blockingOnly, unassignedOnly, showAll)\nif err != nil {\n    if strings.Contains(err.Error(), \"querying epics\") {\n        log.Printf(\"epic query failed: %v\", errors.Unwrap(err))\n    }\n    return err\n}","preventionTips":["Run bd doctor to catch corrupt epic/dependency rows early","In proxied mode, verify daemon connectivity before batch scans","Complete interrupted syncs before running staleness analysis"],"tags":["go","storage","dolt","query","stale"],"backgroundTag":"epic-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}