gastownhall/beads · error
search gates: %w
Error message
search gates: %w
What it means
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.
Source
Thrown at cmd/bd/gate_discover.go:388
}
return false
}
// findPendingGates returns open gh:run gates that need run ID discovery.
// This includes gates with empty AwaitID OR non-numeric AwaitID (workflow name hint).
func findPendingGates() ([]*types.Issue, error) {
var gates []*types.Issue
gateType := types.IssueType("gate")
filter := types.IssueFilter{
IssueType: &gateType,
ExcludeStatus: []types.Status{types.StatusClosed},
}
allGates, err := store.SearchIssues(rootCtx, "", filter)
if err != nil {
return nil, fmt.Errorf("search gates: %w", err)
}
for _, g := range allGates {
if needsDiscovery(g) {
gates = append(gates, g)
}
}
return gates, nil
}
// getGitBranchForGateDiscovery returns the current git branch name
// Uses CWD repo context since this is for user's project CI discovery
func getGitBranchForGateDiscovery() string {
rc, err := beads.GetRepoContext()
if err != nil {
return "main" // Default fallback
}View on GitHub (pinned to 71377f2769)
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
Example fix
// before $ bd gate discover Error: search gates: database is locked // after $ bd dolt pull && bd gate discover
Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: confirm the store is reachable before running discovery
if _, err := store.SearchIssues(ctx, "", types.IssueFilter{Limit: ptr(1)}); err != nil {
return fmt.Errorf("store unreachable, aborting discovery: %w", err)
} Try / catch
gates, err := findPendingGates()
if err != nil {
var derr *store.DBError
if errors.As(err, &derr) {
// database-level failure: surface `bd doctor` / repair guidance
return fmt.Errorf("gate search failed at storage layer: %w", err)
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- ErrExec
- database not available: %w
- database not available: %w
- failed to get template: %w
- db: SetLocalMetadata %s: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/75a8ac654cf39d61.
Report an issue: GitHub.