{"record":{"id":"1e4224408efe72be","repo":"gastownhall/beads","slug":"load-wisp-labels-w","errorCode":null,"errorMessage":"load wisp labels: %w","messagePattern":"load wisp labels: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/export_source.go","lineNumber":265,"sourceCode":"\tif err != nil {\n\t\treturn exportRelations{}, fmt.Errorf(\"load labels: %w\", err)\n\t}\n\tmergeExportMap(rel.labels, labels)\n\tcomments, err := s.uw.CommentUseCase().GetCommentsForIssues(ctx, allIDs)\n\tif err != nil {\n\t\treturn exportRelations{}, fmt.Errorf(\"load comments: %w\", err)\n\t}\n\tmergeExportMap(rel.comments, comments)\n\tcounts, err := s.uw.CommentUseCase().GetCommentCounts(ctx, allIDs)\n\tif err != nil {\n\t\treturn exportRelations{}, fmt.Errorf(\"load comment counts: %w\", err)\n\t}\n\tmergeExportMap(rel.commentCounts, counts)\n\n\twispLabels, err := s.uw.LabelUseCase().GetLabelsForWisps(ctx, allIDs) //nolint:forbidigo // bulk relation load; see GetLabelsForIssues above\n\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 {","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/export_source.go#L247-L283","documentation":"This error wraps a failure from `LabelUseCase().GetLabelsForWisps(ctx, allIDs)` while bulk-loading label relations for wisp-plane issues during export. The wrapper exists so the underlying storage/DB error is attributed to the 'load wisp labels' step of LoadExportRelations. It is deliberately suppressed (not returned) when the error is dberrors.IsTableNotExist, because a rig without wisp tables simply has no labels; so this error only fires for real storage failures.","triggerScenarios":"Calling LoadExportRelations (via bd export) when GetLabelsForWisps returns a non-nil error that is NOT a missing-table error — e.g. Dolt connection failure, corrupted label/wisp_label table, context cancellation, or SQL error querying labels for the given wisp IDs.","commonSituations":"Running `bd export` against a rig whose Dolt server is down or unreachable; a partially-initialized database where the label table is corrupt or schema-migration failed; the context being cancelled mid-export (Ctrl-C or timeout); disk/IO errors on the Dolt database.","solutions":["Check the wrapped cause (printed after the %w chain) — if it is a connection error, ensure the Dolt server/database backing the rig is running and reachable","Run `bd doctor` (or the storage-layer doctor checks) to verify DB integrity and schema state","If the wrapped error is table-not-exist related but not detected, verify dberrors.IsTableNotExist covers your driver's error; consider re-running after schema migration completes","Re-run the export with a fresh context; if it was a transient cancellation or timeout, retry"],"exampleFix":"// before: export fails with opaque wrapped error\nlabels, err := s.uw.LabelUseCase().GetLabelsForWisps(ctx, allIDs)\n// after: inspect the underlying cause and fail loudly only on non-transient errors\nlabels, err := s.uw.LabelUseCase().GetLabelsForWisps(ctx, allIDs)\nif err != nil {\n    if dberrors.IsTableNotExist(err) { labels = nil } else { return exportRelations{}, fmt.Errorf(\"load wisp labels: %w\", err) }\n}","handlingStrategy":"try-catch","validationCode":"// Go has no pre-call validation for DB health; optionally ping the store first\nif err := store.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"storage backend unreachable before export: %w\", err)\n}","typeGuard":"func isTableNotExist(err error) bool { return dberrors.IsTableNotExist(err) }","tryCatchPattern":"wispLabels, err := s.uw.LabelUseCase().GetLabelsForWisps(ctx, allIDs)\nif err != nil {\n    if dberrors.IsTableNotExist(err) {\n        wispLabels = nil // legacy rig: no wisp plane\n    } else {\n        return fmt.Errorf(\"load wisp labels: %w\", err)\n    }\n}","preventionTips":["Ensure the Dolt server/storage backend is healthy before running exports","Keep schema migrations current (`bd migrate` / bd doctor)","Use a context with an adequate timeout so large exports aren't cancelled mid-query","Check the wrapped cause with errors.Unwrap/%+v to fix the root storage error, not just the prefix"],"tags":["go","export","storage","dolt","error-wrapping"],"backgroundTag":"database-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}