{"record":{"id":"26850cba5c02447e","repo":"gastownhall/beads","slug":"querying-blocked-issues-w","errorCode":null,"errorMessage":"querying blocked issues: %w","messagePattern":"querying blocked issues: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/mol_stale.go","lineNumber":142,"sourceCode":"\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\n\t\t}\n\n\t\t// Skip if no children and not showing all\n\t\tif es.TotalChildren == 0 && !showAll {\n\t\t\tcontinue\n\t\t}","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/mol_stale.go#L124-L160","documentation":"findStaleMolecules aggregates stale molecules and needs the set of currently blocked issues to compute what each stale molecule blocks. When the underlying storage query GetBlockedIssues fails (backend/driver error, context cancellation, store not initialized), the error is wrapped with %w and propagated to runMolStale, aborting the command.","triggerScenarios":"Calling `bd mol stale` (directly or via runMolStaleProxiedServer) when the underlying store's GetBlockedIssues(ctx, types.WorkFilter{}) call fails — e.g. database unavailable/corrupt, driver error, or context canceled mid-query.","commonSituations":"Running mol stale against a Dolt database that is offline or unreachable; a partially synced or corrupted database; running the command in proxied-server mode where the backing store connection dropped; Ctrl-C during the query.","solutions":["Check database availability and re-run `bd mol stale` (verify with `bd doctor` or a simple `bd list`).","Inspect the wrapped cause (%w) printed after 'querying blocked issues:' for the driver-level error and fix that first.","If running in proxied-server mode, restart the server process to re-establish the store connection.","Re-sync the database (`bd dolt pull`) if corruption or stale refs are suspected."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Go: check store health before invoking the command\nif err := store.HealthCheck(ctx); err != nil {\n    return fmt.Errorf(\"database unavailable, fix storage before `bd mol stale`: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if _, err := runMolStale(cmd, args); err != nil {\n    if strings.Contains(err.Error(), \"querying blocked issues\") {\n        // inspect wrapped cause, check DB connectivity, retry once\n    }\n    return err\n}","preventionTips":["Keep the local Dolt/store process running and reachable before running mol commands","Run `bd doctor` to catch storage problems early","Avoid killing the process mid-query (signals produce context cancellation)","Periodically `bd dolt pull` to keep the database consistent"],"tags":["go","storage","query"],"backgroundTag":"storage-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}