{"record":{"id":"76309876cb4c52da","repo":"gastownhall/beads","slug":"getstaleissues-w","errorCode":null,"errorMessage":"GetStaleIssues: %w","messagePattern":"GetStaleIssues: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/issue.go","lineNumber":1865,"sourceCode":"\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\n}\n\nfunc (u *issueUseCaseImpl) GetEpicsEligibleForClosure(ctx context.Context) ([]*types.EpicStatus, error) {\n\tout, err := u.issueRepo.GetEpicsEligibleForClosure(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"GetEpicsEligibleForClosure: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (u *issueUseCaseImpl) Unclaim(ctx context.Context, id, actor string, force bool) error {\n\tif id == \"\" {\n\t\treturn fmt.Errorf(\"Unclaim: id must not be empty\")\n\t}\n\tif err := u.issueRepo.UnclaimIssue(ctx, id, actor, force); err != nil {\n\t\treturn fmt.Errorf(\"Unclaim: %w\", err)","sourceCodeStart":1847,"sourceCodeEnd":1883,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/issue.go#L1847-L1883","documentation":"Wrapped error from GetStaleIssues in the issue use-case layer. The repo call issueRepo.GetStaleIssues is invoked with a StaleFilter; any repository failure is returned with a \"GetStaleIssues: \" prefix. This error always indicates a failure beneath the use-case layer, not a validation failure.","triggerScenarios":"Calling GetStaleIssues(ctx, filter) when the repository query fails: bad connection, SQL/Dolt error, or an invalid StaleFilter value that the query layer rejects.","commonSituations":"Running bd's stale-issue scans when the database is unreachable or mid-migration; constructing a StaleFilter with unsupported values that break the query.","solutions":["Unwrap the error to identify the repository-level cause","Validate the StaleFilter fields (statuses, age thresholds) before calling","Check database connectivity and schema state","Retry if the wrapped error is transient"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if filter.Limit < 0 || len(filter.Statuses) == 0 {\n\treturn fmt.Errorf(\"invalid StaleFilter: limit=%d statuses=%v\", filter.Limit, filter.Statuses)\n}","typeGuard":null,"tryCatchPattern":"issues, err := uc.GetStaleIssues(ctx, filter)\nif err != nil {\n\treturn fmt.Errorf(\"stale scan failed: %w\", err)\n}","preventionTips":["Validate StaleFilter fields against the allowed values before calling","Health-check DB connectivity before scheduled stale scans","Log the wrapped cause, not just the prefix"],"tags":["storage","error-wrapping","stale-issues"],"backgroundTag":"repo-error-wrapping","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}