{"record":{"id":"b744174eaf847b37","repo":"gastownhall/beads","slug":"iter-dependents-s-w","errorCode":null,"errorMessage":"iter dependents %s: %w","messagePattern":"iter dependents (.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/workapi/detail.go","lineNumber":203,"sourceCode":"\t\t\tPriority:  item.Issue.Priority,\n\t\t\tTitle:     item.Issue.Title,\n\t\t},\n\t\tDependencyType: item.DependencyType,\n\t}\n}\n\n// collectDependents streams the dependents and keeps only the\n// identity-and-shape fields of each.\n//\n// be-4d36f2: hub beads with thousands of dependents made `bd show --json\n// <hub>` allocate 5-13 GB marshaling full Issue records. The shallow shape\n// preserves what callers consume (id, status, type, priority, title) and\n// drops the free-form text; streaming keeps the full rows from piling up\n// while we do it.\nfunc collectDependents(ctx context.Context, src DetailSource, id string, isWisp bool) ([]*types.IssueWithDependencyMetadata, error) {\n\titer, err := src.IterDependents(ctx, id, isWisp)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"iter dependents %s: %w\", id, err)\n\t}\n\tdefer iter.Close() //nolint:errcheck // read-only iterator\n\n\tvar out []*types.IssueWithDependencyMetadata\n\tfor iter.Next(ctx) {\n\t\titem := iter.Value()\n\t\tif item == nil {\n\t\t\tcontinue\n\t\t}\n\t\tout = append(out, shallowDep(item))\n\t}\n\tif err := iter.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"iter dependents %s: %w\", id, err)\n\t}\n\treturn out, nil\n}\n\nfunc collectComments(ctx context.Context, src DetailSource, id string, isWisp bool) ([]*types.Comment, error) {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/workapi/detail.go#L185-L221","documentation":"collectDependents wraps any error from IterDependents in \"iter dependents %s: %w\", annotating which issue's dependents failed to iterate. BuildIssueDetails calls this while assembling detail payloads, so a storage/iterator failure surfaces with the offending id as context.","triggerScenarios":"src.IterDependents returning an error for the given id (storage failure, closed backend, context cancellation during dependency iteration) inside BuildIssueDetails.","commonSituations":"Database connection dropped mid-detail-build; context deadline exceeded while iterating many dependents; storage seam misconfigured for the wisp/issue table being queried.","solutions":["Inspect the wrapped (%w) inner error for the root storage cause","Retry the detail build with a fresh context if it was cancellation/deadline related","Verify the DetailSource backend is healthy (connectivity, schema) before rebuilding"],"exampleFix":"// before\nctx := context.Background()\ndetails, err := api.BuildIssueDetails(ctx, ids)\n// after\nctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\ndefer cancel()\ndetails, err := api.BuildIssueDetails(ctx, ids)\nif err != nil {\n    var target *storage.Err\n    if errors.As(err, &target) { /* reconnect / retry backend */ }\n}","handlingStrategy":"retry","validationCode":"// Pre-flight: ensure the source backend is reachable before building details\nif err := src.Ping(ctx); err != nil { return fmt.Errorf(\"detail source unavailable: %w\", err) }","typeGuard":null,"tryCatchPattern":"details, err := api.BuildIssueDetails(ctx, ids)\nif err != nil && strings.Contains(err.Error(), \"iter dependents\") {\n    return retryWithBackoff(ctx, 3, func() error {\n        var rerr error\n        details, rerr = api.BuildIssueDetails(ctx, ids)\n        return rerr\n    })\n}","preventionTips":["Use a context with a sane timeout for detail builds","Unwrap the %w chain to inspect the root storage error before retrying","Monitor backend connectivity; reconnect on transient iterator failures"],"tags":["iteration","dependents","storage","error-wrapping"],"backgroundTag":"iterator-failure","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}