{"record":{"id":"6986ae9ac2da5a38","repo":"gastownhall/beads","slug":"searching-closed-gates-w","errorCode":null,"errorMessage":"searching closed gates: %w","messagePattern":"searching closed gates: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/mol_ready_gated.go","lineNumber":140,"sourceCode":"//\n// Logic:\n// 1. Find all closed gate beads\n// 2. For each closed gate, find what step it was blocking\n// 3. Check if that step is now ready (unblocked)\n// 4. Find the parent molecule\n// 5. Filter out molecules that are already hooked by someone\nfunc findGateReadyMolecules(ctx context.Context, s molReader) ([]*GatedMolecule, error) {\n\t// Step 1: Find all closed gate beads\n\tgateType := types.IssueType(\"gate\")\n\tclosedStatus := types.StatusClosed\n\tgateFilter := types.IssueFilter{\n\t\tIssueType: &gateType,\n\t\tStatus:    &closedStatus,\n\t}\n\n\tclosedGates, err := s.SearchIssues(ctx, \"\", gateFilter)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"searching closed gates: %w\", err)\n\t}\n\n\tif len(closedGates) == 0 {\n\t\treturn nil, nil\n\t}\n\n\t// Step 2: Get ready work to check which steps are ready\n\treadyIssues, err := s.GetReadyWork(ctx, types.WorkFilter{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting ready work: %w\", err)\n\t}\n\treadyIDs := make(map[string]bool)\n\tfor _, issue := range readyIssues {\n\t\treadyIDs[issue.ID] = true\n\t}\n\n\t// Step 3: Get hooked molecules to filter out\n\thookedStatus := types.StatusHooked","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/mol_ready_gated.go#L122-L158","documentation":"findGateReadyMolecules first searches for all closed gate issues of a given type. If s.SearchIssues fails, the error is wrapped as 'searching closed gates: %w'. This means the underlying issue search against the Dolt-backed store (or proxy server) returned an error, so gate readiness cannot be determined.","triggerScenarios":"Calling bd mol ready (gated path) when the storage backend search fails: corrupt/unavailable Dolt database, proxied server returning an error for the gate-type/status-filtered query, or an invalid gateType filter value rejected by the search layer.","commonSituations":"Database file locked or migrated to an incompatible schema version; running against a proxied daemon that lost its connection to the backing store; custom gate type strings that fail query validation.","solutions":["Check the wrapped cause (%w) to see the underlying SearchIssues error and fix the storage/server issue first","Verify the database is reachable and schema is current: run bd doctor and any pending migrations","If proxied, confirm the bd daemon/server is running and the client can reach it","Retry the command after resolving the transient storage error"],"exampleFix":"// before: opaque failure\nclosedGates, err := s.SearchIssues(ctx, \"\", gateFilter)\n// after: surface cause and gate type for diagnosis\nclosedGates, err := s.SearchIssues(ctx, \"\", gateFilter)\nif err != nil {\n    return nil, fmt.Errorf(\"searching closed gates (type=%s): %w\", gateType, err)\n}","handlingStrategy":"try-catch","validationCode":"// Go: verify storage is reachable before the gated-ready call\nif err := s.SearchIssues(ctx, \"\", types.IssueFilter{Limit: ptr(1)}); err != nil {\n    return fmt.Errorf(\"storage unavailable: %w\", err)\n}","typeGuard":"func storageOK(s molStore) bool { return s != nil }","tryCatchPattern":"ready, err := findGateReadyMolecules(ctx, s, gateType)\nif err != nil {\n    var wrapped error\n    if errors.As(err, &wrapped) {\n        log.Printf(\"gate search failed: %v (cause: %v)\", err, errors.Unwrap(err))\n    }\n    return err\n}","preventionTips":["Always run bd doctor after upgrading bd versions","Open storage once at command start and fail fast on init errors","In proxied mode, health-check the daemon before issuing queries"],"tags":["go","storage","dolt","search"],"backgroundTag":"storage-search-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}