gastownhall/beads · error

failed to get all dependency records: %w

Error message

failed to get all dependency records: %w

What it means

This error wraps failures from GetAllDependencyRecords inside countCrossRepoEdges, which loads every dependency record in the database to compute incoming edges — dependencies whose resolved target (DependsOnID) is in the migration set but whose owning issue_id is not. It means the full dependency-table scan failed while building migration statistics. The wrapped error holds the underlying cause.

Source

Thrown at cmd/bd/migrate_issues.go:453

	}

	// Count outgoing edges: migrated issues depend on external issues
	outgoing := 0
	for _, deps := range depsByIssue {
		for _, dep := range deps {
			if !setMap[dep.DependsOnID] {
				outgoing++
			}
		}
	}

	// For incoming edges, we need to find all deps whose resolved target is in
	// the migration set but whose issue_id is not. Use GetAllDependencyRecords;
	// the returned records expose the target via dep.DependsOnID (resolved from
	// the typed columns).
	allDeps, err := s.GetAllDependencyRecords(ctx)
	if err != nil {
		return dependencyStats{}, fmt.Errorf("failed to get all dependency records: %w", err)
	}

	incoming := 0
	for issueID, deps := range allDeps {
		if setMap[issueID] {
			continue // Skip edges from within the migration set
		}
		for _, dep := range deps {
			if setMap[dep.DependsOnID] {
				incoming++
			}
		}
	}

	return dependencyStats{
		incomingEdges: incoming,
		outgoingEdges: outgoing,
	}, nil

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped error for the root storage cause
  2. Run `bd doctor` to check dependency-table health
  3. Retry when the database is not under concurrent write load
  4. For very large tables, migrate in smaller filtered batches to reduce scan pressure
Defensive patterns

Strategy: retry

Validate before calling

# check dependency-table health and size before large migrations
bd doctor
bd deps --json | jq 'length'

Try / catch

err := runMigrate()
if err != nil && strings.Contains(err.Error(), "failed to get all dependency records") {
    log.Printf("full dep scan failed (%v); retrying once", errors.Unwrap(err))
    err = runMigrate()
}

Prevention

When it happens

Trigger: s.GetAllDependencyRecords(ctx) returns an error while computing incoming cross-repo edges during expandMigrationSet.

Common situations: Databases with very large dependency tables hitting scan timeouts or memory limits; corrupted dependency rows; storage backend unavailable mid-command.

Related errors


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