{"record":{"id":"3f5842d0501f4ce3","repo":"gastownhall/beads","slug":"get-labels-bulk-w","errorCode":null,"errorMessage":"get labels bulk: %w","messagePattern":"get labels bulk: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/label.go","lineNumber":216,"sourceCode":"\t}\n\treturn out, nil\n}\n\nfunc (u *labelUseCaseImpl) GetLabelsForIssues(ctx context.Context, issueIDs []string) (map[string][]string, error) {\n\treturn u.listBulk(ctx, issueIDs, false)\n}\n\nfunc (u *labelUseCaseImpl) GetLabelsForWisps(ctx context.Context, wispIDs []string) (map[string][]string, error) {\n\treturn u.listBulk(ctx, wispIDs, true)\n}\n\nfunc (u *labelUseCaseImpl) listBulk(ctx context.Context, ids []string, useWisp bool) (map[string][]string, error) {\n\tif len(ids) == 0 {\n\t\treturn map[string][]string{}, nil\n\t}\n\tout, err := u.labelRepo.ListByIssueIDs(ctx, ids, LabelOpts{UseWispsTable: useWisp})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get labels bulk: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (u *labelUseCaseImpl) InheritFromParent(ctx context.Context, childID, parentID, actor string, skipExisting []string) ([]string, error) {\n\treturn u.inherit(ctx, childID, parentID, actor, skipExisting, false)\n}\n\nfunc (u *labelUseCaseImpl) InheritFromWispParent(ctx context.Context, childWispID, parentWispID, actor string, skipExisting []string) ([]string, error) {\n\treturn u.inherit(ctx, childWispID, parentWispID, actor, skipExisting, true)\n}\n\nfunc (u *labelUseCaseImpl) inherit(ctx context.Context, childID, parentID, actor string, skipExisting []string, useWisp bool) ([]string, error) {\n\tif childID == \"\" {\n\t\treturn nil, fmt.Errorf(\"inherit labels: childID must not be empty\")\n\t}\n\tif parentID == \"\" {\n\t\treturn nil, fmt.Errorf(\"inherit labels: parentID must not be empty\")","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/label.go#L198-L234","documentation":"This error wraps a failure from the label repository's bulk lookup (labelRepo.ListByIssueIDs) when fetching labels for multiple issues at once. The use-case layer (listBulk in internal/storage/domain/label.go) adds the 'get labels bulk:' prefix so the caller knows the failure happened during bulk label retrieval rather than a single-issue operation. The underlying cause is stored via %w and can be inspected with errors.Is/As.","triggerScenarios":"Calling GetLabelsForIssues or GetLabelsForWisps with a non-empty ID list when the underlying repository query fails: database unavailable/corrupt, table missing, context canceled mid-query, or UseWispsTable routing to a missing/broken wisps table.","commonSituations":"Bulk-exporting issues where the Dolt database file is locked or the .beads database was partially migrated; running with a stale context after a timeout; querying wisps labels before the wisps table exists in an older database.","solutions":["Inspect the wrapped cause with errors.Unwrap / %v of the error to see the underlying repository failure (connection, schema, context).","Verify the database is reachable and not locked (close other bd processes, check the Dolt database files).","If UseWispsTable is involved, confirm the wisps table exists / the database has been migrated.","Retry with a fresh, non-canceled context; check for timeout/cancellation of the passed ctx."],"exampleFix":"// before\nlabels, err := uc.GetLabelsForIssues(ctx, ids)\nif err != nil { return err } // opaque wrap\n// after\nlabels, err := uc.GetLabelsForIssues(ctx, ids)\nif err != nil {\n    if ctx.Err() != nil { return fmt.Errorf(\"canceled: %w\", ctx.Err()) }\n    return fmt.Errorf(\"bulk labels: %w\", err) // log unwrapped cause\n}","handlingStrategy":"try-catch","validationCode":"// before calling\nif len(ids) == 0 { return map[string][]string{}, nil }\nif ctx.Err() != nil { return ctx.Err() }","typeGuard":null,"tryCatchPattern":"out, err := uc.GetLabelsForIssues(ctx, ids)\nif err != nil {\n    var ctxErr = ctx.Err()\n    if ctxErr != nil { return fmt.Errorf(\"canceled: %w\", ctxErr) }\n    return fmt.Errorf(\"bulk labels: %w\", err)\n}","preventionTips":["Check ctx.Err() before bulk queries.","Keep database migrations current so wisps/labels tables exist.","Avoid running concurrent bd writers that lock the database."],"tags":["go","database","labels","bulk-query"],"backgroundTag":"bulk-label-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}