gastownhall/beads · error
load wisp comment counts: %w
Error message
load wisp comment counts: %w
What it means
This error wraps a failure from `CommentUseCase().GetWispCommentCounts(ctx, allIDs)`, the aggregate comment-count query for wisps, during LoadExportRelations. Missing wisp tables are tolerated via dberrors.IsTableNotExist; all other failures abort the export wrapped with this 'load wisp comment counts' prefix.
Source
Thrown at cmd/bd/export_source.go:281
if err != nil {
if !dberrors.IsTableNotExist(err) {
return exportRelations{}, fmt.Errorf("load wisp labels: %w", err)
}
} else {
mergeExportMap(rel.labels, wispLabels)
}
wispComments, err := s.uw.CommentUseCase().GetCommentsForWisps(ctx, allIDs)
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 {View on GitHub (pinned to 71377f2769)
Solutions
- Inspect the wrapped cause; for connection/timeout errors, restart the Dolt server or increase the query timeout, then re-run the export
- Run `bd doctor`/migrations if the underlying SQL fails (possible schema drift)
- Reduce export batch size so the aggregate query completes within limits
- Retry the export after confirming the storage backend is healthy
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure storage is reachable before aggregate queries
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
wispCounts, err := s.uw.CommentUseCase().GetWispCommentCounts(ctx, allIDs)
if err != nil {
if !dberrors.IsTableNotExist(err) {
return fmt.Errorf("load wisp comment counts: %w", err)
}
} Prevention
- Batch very large ID sets so COUNT aggregations complete within query timeouts
- Keep the database schema migrated; corrupt/stale comment tables break aggregation
- Retry transient backend outages before investigating deeper
- Diagnose via the wrapped cause rather than the wrapper prefix alone
When it happens
Trigger: Calling LoadExportRelations when the aggregate COUNT query for wisp comments fails with anything other than table-not-exist: SQL aggregation error, storage backend down, cancelled context, or a malformed allIDs batch.
Common situations: Large exports timing out on aggregate queries; Dolt server restarts mid-export; driver version mismatch producing SQL syntax errors on COUNT queries; DB corruption in the comments table affecting aggregation.
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 wisp labels: %w
- load wisp comments: %w
- load dependency records: %w
- wisp plane membership: %w
- no storage backend is open
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/57c6f8f3fd7f6e48.
Report an issue: GitHub.