gastownhall/beads · error

querying epics: %w

Error message

querying epics: %w

What it means

findStaleMolecules first queries all epics eligible for closure via GetEpicsEligibleForClosure. A failure there is wrapped as 'querying epics: %w', so bd mol stale cannot enumerate stale molecule candidates.

Source

Thrown at cmd/bd/mol_stale.go:136

				ui.RenderID(mol.ID), mol.Title, progress)
			fmt.Printf("       → Close with: bd close %s\n", mol.ID)
		}
		fmt.Println()
	}

	fmt.Printf("Total: %d stale", result.TotalCount)
	if result.BlockingCount > 0 {
		fmt.Printf(", %d blocking other work", result.BlockingCount)
	}
	fmt.Println()
}

// findStaleMolecules queries the database for stale molecules
func findStaleMolecules(ctx context.Context, s molReader, blockingOnly, unassignedOnly, showAll bool) (*StaleResult, error) {
	// Get all epics eligible for closure (complete but unclosed)
	epicStatuses, err := s.GetEpicsEligibleForClosure(ctx)
	if err != nil {
		return nil, fmt.Errorf("querying epics: %w", err)
	}

	// Get blocked issues to find what each stale molecule is blocking
	blockedIssues, err := s.GetBlockedIssues(ctx, types.WorkFilter{})
	if err != nil {
		return nil, fmt.Errorf("querying blocked issues: %w", err)
	}

	// Build map of issue ID -> what issues it's blocking
	blockingMap := buildBlockingMap(blockedIssues)

	var staleMolecules []*StaleMolecule
	blockingCount := 0

	for _, es := range epicStatuses {
		// Skip if not eligible for close (not all children closed)
		if !es.EligibleForClose {
			continue

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped cause and fix the underlying storage/server error first
  2. Run bd doctor to validate database integrity and schema version
  3. If proxied, confirm the daemon is reachable and retry
  4. Retry bd stale once the query layer is healthy
Defensive patterns

Strategy: try-catch

Validate before calling

// Health-check storage before stale scan
if err := s.GetBlockedIssues(ctx, types.WorkFilter{Limit: 1}); err != nil {
    return fmt.Errorf("storage unavailable: %w", err)
}

Type guard

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

Try / catch

res, err := findStaleMolecules(ctx, s, blockingOnly, unassignedOnly, showAll)
if err != nil {
    if strings.Contains(err.Error(), "querying epics") {
        log.Printf("epic query failed: %v", errors.Unwrap(err))
    }
    return err
}

Prevention

When it happens

Trigger: bd mol stale when the epic-closure query fails: database unavailable, epic eligibility query error, proxied server returning an error, or schema mismatch.

Common situations: Dolt server down in proxied mode; corrupt or partially-migrated database; interrupted sync leaving inconsistent epic/dependency rows.

Related errors


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