gastownhall/beads · error

read comments for %s: %w

Error message

read comments for %s: %w

What it means

copyIssueRelations reads the issue's comments with src.GetIssueComments; a read failure aborts the migration with this wrapped error so no comment is silently lost.

Source

Thrown at cmd/bd/migrate_personal.go:227

	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
}

func pluralIssue(n int) string {
	if n == 1 {
		return "issue"
	}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped inner error for the driver-level cause.
  2. Verify source DB health (bd doctor) and that no other process holds the lock.
  3. Fix access and re-run migration; the fatal-on-error contract keeps the source intact.
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight comment read
if _, err := src.GetIssueComments(ctx, issue.ID); err != nil {
    return fmt.Errorf("pre-flight comments %s: %w", issue.ID, err)
}

Try / catch

if err := copyIssueRelations(ctx, src, dst, issue, actor); err != nil {
    // err wraps: read comments for <id>: <driver err>
    return err // abort; do not delete source
}

Prevention

When it happens

Trigger: src.GetIssueComments(ctx, issue.ID) returns an error during migration — source driver error, corrupted comment rows, or DB lock.

Common situations: Source database locked by another process, or comment rows damaged by an earlier failed write during a previous migration attempt.

Related errors


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