{"record":{"id":"2361a3c92e777e32","repo":"gastownhall/beads","slug":"load-dependency-counts-w","errorCode":null,"errorMessage":"load dependency counts: %w","messagePattern":"load dependency counts: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/export_source.go","lineNumber":295,"sourceCode":"\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 {\n\t\t// A rig without the wisp tables simply has no wisp-plane edges.\n\t\tif !dberrors.IsTableNotExist(err) {\n\t\t\treturn exportRelations{}, fmt.Errorf(\"load wisp dependency counts: %w\", err)\n\t\t}\n\t} else {\n\t\tfor id, wc := range wispDepCounts {\n\t\t\tif wc == nil || (wc.DependencyCount == 0 && wc.DependentCount == 0) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tc := rel.depCounts[id]\n\t\t\tif c == nil {\n\t\t\t\tc = &types.DependencyCounts{}\n\t\t\t\trel.depCounts[id] = c\n\t\t\t}","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/export_source.go#L277-L313","documentation":"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.","triggerScenarios":"Calling LoadExportRelations when CountsByIssueIDs fails: SQL aggregate error on the dependencies table, storage backend unavailable, cancelled context, or corrupt count data.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// probe storage health and dependencies table presence before exporting\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":"depCounts, err := s.uw.DependencyUseCase().CountsByIssueIDs(ctx, allIDs)\nif err != nil {\n    return fmt.Errorf(\"load dependency counts: %w\", err)\n}","preventionTips":["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"],"tags":["go","export","dependencies","counts","dolt"],"backgroundTag":"database-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}