gastownhall/beads · error

load wisp dependency counts: %w

Error message

load wisp dependency counts: %w

What it means

This error wraps a failure from `DependencyUseCase().CountsByWispIDs(ctx, allIDs)`, which loads per-wisp dependency counts for the wisp plane during export. The code comment states the intent: a rig without wisp tables has no wisp-plane edges, so dberrors.IsTableNotExist errors are swallowed; any other error is fatal and wrapped with this prefix.

Source

Thrown at cmd/bd/export_source.go:302

		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
			}
			c := rel.depCounts[id]
			if c == nil {
				c = &types.DependencyCounts{}
				rel.depCounts[id] = c
			}
			c.DependencyCount += wc.DependencyCount
			c.DependentCount += wc.DependentCount
		}
	}

	return rel, nil
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped cause and fix the underlying storage issue (connectivity, locks, corruption)
  2. Run `bd doctor`/migrations if wisp tables exist but are unhealthy
  3. If your driver's missing-table error isn't matched by dberrors.IsTableNotExist, upgrade beads or the driver so legacy rigs are correctly tolerated
  4. Retry the export after backend health is confirmed
Defensive patterns

Strategy: try-catch

Validate before calling

// wisp dependency counts are optional; nothing to validate — ensure backend is reachable
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

wispDepCounts, err := s.uw.DependencyUseCase().CountsByWispIDs(ctx, allIDs)
if err != nil {
    if !dberrors.IsTableNotExist(err) {
        return fmt.Errorf("load wisp dependency counts: %w", err)
    }
    // legacy rig: no wisp tables, no wisp-plane edges
}

Prevention

When it happens

Trigger: Calling LoadExportRelations when CountsByWispIDs fails with a non-table-not-exist error: Dolt connection failure, SQL error on the wisp dependency-count query, cancelled context, or corrupt wisp tables that DO exist but fail to query.

Common situations: A rig where wisp tables exist but are partially migrated or corrupt; backend down mid-export; aggregate query timeout on large wisp sets; driver returning an unexpected error shape not recognized as table-not-exist.

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/b9783d76daf93673. Report an issue: GitHub.