{"record":{"id":"1d164b15808fb7b8","repo":"gastownhall/beads","slug":"history-w","errorCode":null,"errorMessage":"History: %w","messagePattern":"History: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/issue.go","lineNumber":1849,"sourceCode":"\tout, err := u.issueRepo.CountIssues(ctx, query, filter)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"CountIssues: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (u *issueUseCaseImpl) CountIssuesByGroup(ctx context.Context, filter types.IssueFilter, groupBy string) (map[string]int, error) {\n\tout, err := u.issueRepo.CountIssuesByGroup(ctx, filter, groupBy)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"CountIssuesByGroup: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (u *issueUseCaseImpl) History(ctx context.Context, id string) ([]*storage.HistoryEntry, error) {\n\tout, err := u.issueRepo.History(ctx, id)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"History: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (u *issueUseCaseImpl) IterEvents(ctx context.Context, id string, limit int) (storage.Iter[types.Event], error) {\n\tout, err := u.issueRepo.IterEvents(ctx, id, limit)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"IterEvents: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (u *issueUseCaseImpl) GetStaleIssues(ctx context.Context, filter types.StaleFilter) ([]*types.Issue, error) {\n\tout, err := u.issueRepo.GetStaleIssues(ctx, filter)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"GetStaleIssues: %w\", err)\n\t}\n\treturn out, nil","sourceCodeStart":1831,"sourceCodeEnd":1867,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/issue.go#L1831-L1867","documentation":"Pass-through wrapper from History in the issue use-case: wraps errors from issueRepo.History(ctx, id), which fetches the event/audit history entries for an issue. A failure reading history from storage surfaces as 'History: <root cause>'.","triggerScenarios":"Calling History(ctx, id) when the repository's history/event query errors — the issue ID does not exist, the events table is missing/corrupt, or the database is unreachable.","commonSituations":"Requesting history for a typo'd or deleted issue ID; running against a database where the events/history table was pruned or not migrated; connection drop during iteration with a large limit.","solutions":["Inspect the wrapped error after 'History:' for the root cause","Verify the issue ID exists before fetching history","Check the events table exists and the schema is migrated","Retry on transient storage errors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if id == \"\" {\n    return nil, fmt.Errorf(\"history: empty issue id\")\n}","typeGuard":"func hasID(id string) bool { return strings.TrimSpace(id) != \"\" }","tryCatchPattern":"entries, err := uc.History(ctx, id)\nif err != nil {\n    log.Warnf(\"history unavailable for %s: %v\", id, err)\n    return nil\n}","preventionTips":["Verify the issue exists before fetching history","Keep the events/history schema migrated and avoid manual pruning","Retry transient storage errors","Validate IDs at CLI/agent boundaries before storage calls"],"tags":["go","storage","error-wrapping","history","events"],"backgroundTag":"repository-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}