{"record":{"id":"b9783d76daf93673","repo":"gastownhall/beads","slug":"load-wisp-dependency-counts-w","errorCode":null,"errorMessage":"load wisp dependency counts: %w","messagePattern":"load wisp dependency counts: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/export_source.go","lineNumber":302,"sourceCode":"\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}\n\t\t\tc.DependencyCount += wc.DependencyCount\n\t\t\tc.DependentCount += wc.DependentCount\n\t\t}\n\t}\n\n\treturn rel, nil\n}","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/export_source.go#L284-L320","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the wrapped cause and fix the underlying storage issue (connectivity, locks, corruption)","Run `bd doctor`/migrations if wisp tables exist but are unhealthy","If your driver's missing-table error isn't matched by dberrors.IsTableNotExist, upgrade beads or the driver so legacy rigs are correctly tolerated","Retry the export after backend health is confirmed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// wisp dependency counts are optional; nothing to validate — ensure backend is reachable\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":"wispDepCounts, err := s.uw.DependencyUseCase().CountsByWispIDs(ctx, allIDs)\nif err != nil {\n    if !dberrors.IsTableNotExist(err) {\n        return fmt.Errorf(\"load wisp dependency counts: %w\", err)\n    }\n    // legacy rig: no wisp tables, no wisp-plane edges\n}","preventionTips":["Keep wisp tables fully migrated; partial migration causes non-tolerated errors","Upgrade beads/driver if your storage's missing-table error isn't recognized by dberrors.IsTableNotExist","Confirm backend health before wisp-aware exports","Distinguish tolerated (table-not-exist) from real errors by inspecting the wrapped cause"],"tags":["go","export","wisps","dependencies","dolt"],"backgroundTag":"database-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}