gastownhall/beads · error

copy dependency %s→%s: %w

Error message

copy dependency %s→%s: %w

What it means

When copying a dependency to the destination with dst.AddDependency fails, the migration aborts with this error identifying the edge (IssueID→DependsOnID).

Source

Thrown at cmd/bd/migrate_personal.go:221

// (maphew review, be-e2nb).
func copyIssueRelations(ctx context.Context, src, dst storage.DoltStorage, issue *types.Issue, actor string) error {
	labels, err := src.GetLabels(ctx, issue.ID)
	if err != nil {
		return fmt.Errorf("read labels for %s: %w", issue.ID, err)
	}
	for _, label := range labels {
		if err := dst.AddLabel(ctx, issue.ID, label, actor); err != nil {
			return fmt.Errorf("copy label %q for %s: %w", label, issue.ID, err)
		}
	}

	deps, err := src.GetDependencyRecords(ctx, issue.ID)
	if err != nil {
		return fmt.Errorf("read dependencies for %s: %w", issue.ID, err)
	}
	for _, dep := range deps {
		if err := dst.AddDependency(ctx, dep, actor); err != nil {
			return fmt.Errorf("copy dependency %s→%s: %w", dep.IssueID, dep.DependsOnID, err)
		}
	}

	comments, err := src.GetIssueComments(ctx, issue.ID)
	if err != nil {
		return fmt.Errorf("read comments for %s: %w", issue.ID, err)
	}
	for _, c := range comments {
		// ImportIssueComment writes a structured comment row preserving the
		// original author and created_at. AddComment would instead record an
		// event-style entry that GetIssueComments never returns, silently
		// dropping the comment from the migrated issue (maphew review, be-e2nb).
		if _, err := dst.ImportIssueComment(ctx, issue.ID, c.Author, c.Text, c.CreatedAt); err != nil {
			return fmt.Errorf("copy comment for %s: %w", issue.ID, err)
		}
	}

	return nil

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped inner error; if it's a missing DependsOnID, ensure migration copies all referenced issues (full-issue set) rather than a subset.
  2. Close other bd processes locking the destination DB and retry.
  3. If duplicate edges from a prior partial run are the cause, reset the destination and migrate fresh.
Defensive patterns

Strategy: validation

Validate before calling

// ensure every dependency target exists in the destination set
for _, dep := range deps {
    if !copiedIDs[dep.DependsOnID] {
        return fmt.Errorf("dep target %s not in migration set", dep.DependsOnID)
    }
}

Prevention

When it happens

Trigger: dst.AddDependency(ctx, dep, actor) errors — e.g. the dependency's target issue (DependsOnID) does not yet exist in the destination, a duplicate dependency, or a driver write failure.

Common situations: Migrating issues out of dependency order so a dep references an issue not yet copied, or destination lock contention while another bd process runs.

Related errors


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