gastownhall/beads · error

failed to search issues: %w

Error message

failed to search issues: %w

What it means

shouldSkipEmptyAutoExport queries the store with SearchIssues using the auto-export filter to decide whether the database is empty enough to skip writing the JSONL. A failed search is wrapped with this message; the caller cannot safely decide, so the auto-export path aborts with an error instead of potentially truncating the export.

Source

Thrown at cmd/bd/export_auto.go:279

func shouldExport(state *exportAutoState, interval time.Duration) bool {
	if state.Timestamp.IsZero() {
		return true
	}
	return time.Since(state.Timestamp) >= interval
}

func shouldSkipEmptyAutoExport(ctx context.Context, path string) (bool, int, error) {
	existingCount, err := countIssueRecordsInJSONL(path)
	if err != nil {
		return false, 0, err
	}
	if existingCount == 0 {
		return false, 0, nil
	}

	issues, err := store.SearchIssues(ctx, "", autoExportFilter(ctx))
	if err != nil {
		return false, 0, fmt.Errorf("failed to search issues: %w", err)
	}

	return len(issues) == 0, existingCount, nil
}

func countIssueRecordsInJSONL(path string) (int, error) {
	ids, err := issueIDsInJSONL(path)
	if err != nil {
		return 0, err
	}
	return len(ids), nil
}

func missingJSONLIssueIDsInStore(ctx context.Context, path, fromCommit string) ([]string, error) {
	// GH#4988: only refuse when *in-scope* JSONL issue records are absent from
	// the store. Ephemeral wisps, templates, and infra types are outside
	// auto-export scope (buildAutoExportFilter / GH#3649). Compaction can
	// delete wisps from Dolt while an older JSONL still lists them; treating

View on GitHub (pinned to 71377f2769)

Solutions

  1. Inspect the wrapped cause; run `bd doctor` for storage health
  2. Retry the export — the failure occurs before any JSONL write, so no data was lost
  3. Ensure the database is reachable and not locked (close competing bd processes)
  4. If the DB is genuinely empty, initialize properly (`bd init`) rather than forcing an export
Defensive patterns

Strategy: retry

Validate before calling

if !dbReachable() { skipAutoExport("store unreachable") }

Try / catch

if err := maybeAutoExport(ctx); err != nil {
    if strings.Contains(err.Error(), "failed to search issues") {
        // safe to retry: no JSONL was written
        time.Sleep(backoff); retryAutoExport()
    }
}

Prevention

When it happens

Trigger: store.SearchIssues(ctx, "", autoExportFilter(ctx)) fails — store nil/uninitialized, Dolt query error, or driver-level failure while listing issues with the applied filter.

Common situations: Auto-export triggered in an environment where DB access is degraded (embedded Dolt lock contention, server unreachable); corrupted local metadata breaking the issue query; running with a filter referencing infrastructure types whose metadata is inconsistent.

Related errors


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