{"record":{"id":"57c6f8f3fd7f6e48","repo":"gastownhall/beads","slug":"load-wisp-comment-counts-w","errorCode":null,"errorMessage":"load wisp comment counts: %w","messagePattern":"load wisp comment counts: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/export_source.go","lineNumber":281,"sourceCode":"\tif err != nil {\n\t\tif !dberrors.IsTableNotExist(err) {\n\t\t\treturn exportRelations{}, fmt.Errorf(\"load wisp labels: %w\", err)\n\t\t}\n\t} else {\n\t\tmergeExportMap(rel.labels, wispLabels)\n\t}\n\twispComments, err := s.uw.CommentUseCase().GetCommentsForWisps(ctx, allIDs)\n\tif err != nil {\n\t\tif !dberrors.IsTableNotExist(err) {\n\t\t\treturn exportRelations{}, fmt.Errorf(\"load wisp comments: %w\", err)\n\t\t}\n\t} else {\n\t\tmergeExportMap(rel.comments, wispComments)\n\t}\n\twispCounts, err := s.uw.CommentUseCase().GetWispCommentCounts(ctx, allIDs)\n\tif err != nil {\n\t\tif !dberrors.IsTableNotExist(err) {\n\t\t\treturn exportRelations{}, fmt.Errorf(\"load wisp comment counts: %w\", err)\n\t\t}\n\t} else {\n\t\tmergeExportMap(rel.commentCounts, wispCounts)\n\t}\n\n\tdeps, err := s.uw.DependencyUseCase().GetIssueDependencyRecords(ctx, allIDs)\n\tif err != nil {\n\t\treturn exportRelations{}, fmt.Errorf(\"load dependency records: %w\", err)\n\t}\n\trel.deps = deps\n\n\tdepCounts, err := s.uw.DependencyUseCase().CountsByIssueIDs(ctx, allIDs)\n\tif err != nil {\n\t\treturn exportRelations{}, fmt.Errorf(\"load dependency counts: %w\", err)\n\t}\n\trel.depCounts = depCounts\n\twispDepCounts, err := s.uw.DependencyUseCase().CountsByWispIDs(ctx, allIDs)\n\tif err != nil {","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/export_source.go#L263-L299","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure storage is reachable before aggregate queries\nif err := store.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"storage backend unreachable: %w\", err)\n}","typeGuard":"func isTableNotExist(err error) bool { return dberrors.IsTableNotExist(err) }","tryCatchPattern":"wispCounts, err := s.uw.CommentUseCase().GetWispCommentCounts(ctx, allIDs)\nif err != nil {\n    if !dberrors.IsTableNotExist(err) {\n        return fmt.Errorf(\"load wisp comment counts: %w\", err)\n    }\n}","preventionTips":["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"],"tags":["go","export","storage","dolt","aggregation"],"backgroundTag":"database-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}