gastownhall/beads · error

load dependency records: %w

Error message

load dependency records: %w

What it means

This error wraps a failure from `DependencyUseCase().GetIssueDependencyRecords(ctx, allIDs)` when loading dependency edges for the issues being exported. Unlike the wisp-plane loaders, there is no table-not-exist tolerance here: dependencies are core-plane data, so any error aborts the export.

Source

Thrown at cmd/bd/export_source.go:289

	if err != nil {
		if !dberrors.IsTableNotExist(err) {
			return exportRelations{}, fmt.Errorf("load wisp comments: %w", err)
		}
	} else {
		mergeExportMap(rel.comments, wispComments)
	}
	wispCounts, err := s.uw.CommentUseCase().GetWispCommentCounts(ctx, allIDs)
	if err != nil {
		if !dberrors.IsTableNotExist(err) {
			return exportRelations{}, fmt.Errorf("load wisp comment counts: %w", err)
		}
	} else {
		mergeExportMap(rel.commentCounts, wispCounts)
	}

	deps, err := s.uw.DependencyUseCase().GetIssueDependencyRecords(ctx, allIDs)
	if err != nil {
		return exportRelations{}, fmt.Errorf("load dependency records: %w", err)
	}
	rel.deps = deps

	depCounts, err := s.uw.DependencyUseCase().CountsByIssueIDs(ctx, allIDs)
	if err != nil {
		return exportRelations{}, fmt.Errorf("load dependency counts: %w", err)
	}
	rel.depCounts = depCounts
	wispDepCounts, err := s.uw.DependencyUseCase().CountsByWispIDs(ctx, allIDs)
	if err != nil {
		// A rig without the wisp tables simply has no wisp-plane edges.
		if !dberrors.IsTableNotExist(err) {
			return exportRelations{}, fmt.Errorf("load wisp dependency counts: %w", err)
		}
	} else {
		for id, wc := range wispDepCounts {
			if wc == nil || (wc.DependencyCount == 0 && wc.DependentCount == 0) {
				continue

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped cause; fix the underlying storage connectivity or restart the Dolt server
  2. Run `bd doctor` and schema migrations — a missing/corrupt dependencies table is serious and will also break other commands
  3. If dependencies are truly absent (fresh DB), verify whether the driver's error is a table-not-exist case that upstream should tolerate; otherwise re-initialize the database
  4. Re-run the export once the backend is healthy

Example fix

// before: any dependency-load error kills the export
deps, err := s.uw.DependencyUseCase().GetIssueDependencyRecords(ctx, allIDs)
if err != nil { return exportRelations{}, fmt.Errorf("load dependency records: %w", err) }
// after: tolerate a genuinely absent table on legacy DBs
deps, err := s.uw.DependencyUseCase().GetIssueDependencyRecords(ctx, allIDs)
if err != nil {
    if !dberrors.IsTableNotExist(err) { return exportRelations{}, fmt.Errorf("load dependency records: %w", err) }
    deps = nil
}
Defensive patterns

Strategy: try-catch

Validate before calling

// dependencies are core-plane; confirm the table exists via doctor or a probe query before export
if err := store.PingContext(ctx); err != nil {
    return fmt.Errorf("storage backend unreachable: %w", err)
}

Type guard

func isTableNotExist(err error) bool { return dberrors.IsTableNotExist(err) }

Try / catch

deps, err := s.uw.DependencyUseCase().GetIssueDependencyRecords(ctx, allIDs)
if err != nil {
    return fmt.Errorf("load dependency records: %w", err)
}

Prevention

When it happens

Trigger: Calling LoadExportRelations when the dependency-records query fails: dependencies table missing/corrupt, Dolt connection failure, SQL error, or context cancellation.

Common situations: A database created before the dependencies schema existed; a corrupt dependencies table after a crashed migration; `bd export` against a down or misconfigured Dolt backend; export cancelled by timeout.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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