{"record":{"id":"75a8ac654cf39d61","repo":"gastownhall/beads","slug":"search-gates-w","errorCode":null,"errorMessage":"search gates: %w","messagePattern":"search gates: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/gate_discover.go","lineNumber":388,"sourceCode":"\t}\n\n\treturn false\n}\n\n// findPendingGates returns open gh:run gates that need run ID discovery.\n// This includes gates with empty AwaitID OR non-numeric AwaitID (workflow name hint).\nfunc findPendingGates() ([]*types.Issue, error) {\n\tvar gates []*types.Issue\n\n\tgateType := types.IssueType(\"gate\")\n\tfilter := types.IssueFilter{\n\t\tIssueType:     &gateType,\n\t\tExcludeStatus: []types.Status{types.StatusClosed},\n\t}\n\n\tallGates, err := store.SearchIssues(rootCtx, \"\", filter)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"search gates: %w\", err)\n\t}\n\n\tfor _, g := range allGates {\n\t\tif needsDiscovery(g) {\n\t\t\tgates = append(gates, g)\n\t\t}\n\t}\n\n\treturn gates, nil\n}\n\n// getGitBranchForGateDiscovery returns the current git branch name\n// Uses CWD repo context since this is for user's project CI discovery\nfunc getGitBranchForGateDiscovery() string {\n\trc, err := beads.GetRepoContext()\n\tif err != nil {\n\t\treturn \"main\" // Default fallback\n\t}","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/gate_discover.go#L370-L406","documentation":"findPendingGates lists open gh:run gates needing run-ID discovery via store.SearchIssues. If the underlying Dolt-backed store query fails (DB unavailable, corrupt schema, context canceled), the error is wrapped as \"search gates: %w\" so callers of `bd gate discover` see the storage-layer cause.","triggerScenarios":"Calling `bd gate discover` when store.SearchIssues on the IssueFilter{IssueType: gate, ExcludeStatus: closed} fails: the Dolt database is unreachable/corrupt, rootCtx is canceled, or the storage driver errors mid-query.","commonSituations":"Dolt server not running or embedded DB locked by another bd process; running the command outside an initialized bd repo; disk/permission problems on the .beads data directory; an interrupted sync leaving the DB in a bad state.","solutions":["Run `bd doctor` to check database health and follow its repair guidance","Verify the Dolt backing store is reachable (start the server / check .beads directory permissions)","Re-run `bd gate discover` in the correct repository root (bd init if the repo was never initialized)","If the DB is corrupt, restore from the git-synced refs/dolt/data or issues.jsonl export"],"exampleFix":"// before\n$ bd gate discover\nError: search gates: database is locked\n// after\n$ bd dolt pull && bd gate discover","handlingStrategy":"try-catch","validationCode":"// preflight: confirm the store is reachable before running discovery\nif _, err := store.SearchIssues(ctx, \"\", types.IssueFilter{Limit: ptr(1)}); err != nil {\n  return fmt.Errorf(\"store unreachable, aborting discovery: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"gates, err := findPendingGates()\nif err != nil {\n  var derr *store.DBError\n  if errors.As(err, &derr) {\n    // database-level failure: surface `bd doctor` / repair guidance\n    return fmt.Errorf(\"gate search failed at storage layer: %w\", err)\n  }\n  return err\n}","preventionTips":["Run `bd doctor` periodically to catch DB corruption early","Avoid running concurrent bd writers that can lock the embedded Dolt DB","Keep `bd dolt pull`/`push` in sync so recovery from git history is possible","Run discovery from the repository root where the bd store is initialized"],"tags":["database","storage","dolt"],"backgroundTag":"database-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}