gastownhall/beads · error
load dependency counts: %w
Error message
load dependency counts: %w
What it means
This error wraps a failure from `DependencyUseCase().CountsByIssueIDs(ctx, allIDs)`, which computes per-issue dependency counts for the export. It is fatal (no table-not-exist tolerance) because dependency counts are core-plane data required to render export relations.
Source
Thrown at cmd/bd/export_source.go:295
}
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
}
c := rel.depCounts[id]
if c == nil {
c = &types.DependencyCounts{}
rel.depCounts[id] = c
}View on GitHub (pinned to 71377f2769)
Solutions
- Inspect the wrapped cause; restart/reconnect the storage backend if it's a connection or lock error
- Run schema migrations / `bd doctor` to fix drift or corruption in the dependencies table
- Retry the export with a smaller batch or after clearing concurrent writers
- Increase query timeouts if aggregation on large sets is the cause
Defensive patterns
Strategy: try-catch
Validate before calling
// probe storage health and dependencies table presence before exporting
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
depCounts, err := s.uw.DependencyUseCase().CountsByIssueIDs(ctx, allIDs)
if err != nil {
return fmt.Errorf("load dependency counts: %w", err)
} Prevention
- Avoid concurrent writers holding locks on the dependencies table during export
- Migrate schema after upgrades so count queries don't hit drifted tables
- Raise query timeouts for large issue batches
- Read the wrapped cause first — this wrapper only names the failing step
When it happens
Trigger: Calling LoadExportRelations when CountsByIssueIDs fails: SQL aggregate error on the dependencies table, storage backend unavailable, cancelled context, or corrupt count data.
Common situations: Exporting a large issue set where the count aggregation times out; Dolt server restarted mid-export; schema drift after upgrading beads without migrating; locked tables from a concurrent writer.
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
- load dependency records: %w
- load wisp dependency counts: %w
- load wisp labels: %w
- load wisp comments: %w
- load wisp comment counts: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/2361a3c92e777e32.
Report an issue: GitHub.