gastownhall/beads · error

searching closed gates: %w

Error message

searching closed gates: %w

What it means

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.

Source

Thrown at cmd/bd/mol_ready_gated.go:140

//
// Logic:
// 1. Find all closed gate beads
// 2. For each closed gate, find what step it was blocking
// 3. Check if that step is now ready (unblocked)
// 4. Find the parent molecule
// 5. Filter out molecules that are already hooked by someone
func findGateReadyMolecules(ctx context.Context, s molReader) ([]*GatedMolecule, error) {
	// Step 1: Find all closed gate beads
	gateType := types.IssueType("gate")
	closedStatus := types.StatusClosed
	gateFilter := types.IssueFilter{
		IssueType: &gateType,
		Status:    &closedStatus,
	}

	closedGates, err := s.SearchIssues(ctx, "", gateFilter)
	if err != nil {
		return nil, fmt.Errorf("searching closed gates: %w", err)
	}

	if len(closedGates) == 0 {
		return nil, nil
	}

	// Step 2: Get ready work to check which steps are ready
	readyIssues, err := s.GetReadyWork(ctx, types.WorkFilter{})
	if err != nil {
		return nil, fmt.Errorf("getting ready work: %w", err)
	}
	readyIDs := make(map[string]bool)
	for _, issue := range readyIssues {
		readyIDs[issue.ID] = true
	}

	// Step 3: Get hooked molecules to filter out
	hookedStatus := types.StatusHooked

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped cause (%w) to see the underlying SearchIssues error and fix the storage/server issue first
  2. Verify the database is reachable and schema is current: run bd doctor and any pending migrations
  3. If proxied, confirm the bd daemon/server is running and the client can reach it
  4. Retry the command after resolving the transient storage error

Example fix

// before: opaque failure
closedGates, err := s.SearchIssues(ctx, "", gateFilter)
// after: surface cause and gate type for diagnosis
closedGates, err := s.SearchIssues(ctx, "", gateFilter)
if err != nil {
    return nil, fmt.Errorf("searching closed gates (type=%s): %w", gateType, err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: verify storage is reachable before the gated-ready call
if err := s.SearchIssues(ctx, "", types.IssueFilter{Limit: ptr(1)}); err != nil {
    return fmt.Errorf("storage unavailable: %w", err)
}

Type guard

func storageOK(s molStore) bool { return s != nil }

Try / catch

ready, err := findGateReadyMolecules(ctx, s, gateType)
if err != nil {
    var wrapped error
    if errors.As(err, &wrapped) {
        log.Printf("gate search failed: %v (cause: %v)", err, errors.Unwrap(err))
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/6986ae9ac2da5a38. Report an issue: GitHub.