{"record":{"id":"51cf0fdbbcf9068c","repo":"gastownhall/beads","slug":"hydrate-ready-row-s-comment-counts-w-51cf0f","errorCode":null,"errorMessage":"hydrate ready row %s: comment counts: %w","messagePattern":"hydrate ready row (.+?): comment counts: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/uow/ready_claimer.go","lineNumber":112,"sourceCode":"\n// hydrateReadyRow fills in the relationship cardinalities a ready row carries,\n// reading them in the caller's unit of work so the counts describe the state\n// that transaction is about to commit. A failed count read is an error rather\n// than a zero, matching the store-backed sibling: a result nobody can hydrate\n// is not a result.\nfunc hydrateReadyRow(ctx context.Context, uw UnitOfWork, issue *types.Issue) (*types.IssueWithCounts, error) {\n\tids := []string{issue.ID}\n\tdepCounts, err := uw.DependencyUseCase().CountsByIssueIDs(ctx, ids)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"hydrate ready row %s: dependency counts: %w\", issue.ID, err)\n\t}\n\trecords, err := uw.DependencyUseCase().GetForIssueIDs(ctx, ids)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"hydrate ready row %s: dependency records: %w\", issue.ID, err)\n\t}\n\tcommentCounts, err := uw.CommentUseCase().GetCommentCounts(ctx, ids)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"hydrate ready row %s: comment counts: %w\", issue.ID, err)\n\t}\n\n\tissue.Dependencies = records[issue.ID]\n\tcounts := depCounts[issue.ID]\n\tif counts == nil {\n\t\tcounts = &types.DependencyCounts{}\n\t}\n\tvar parent *string\n\tfor _, dep := range records[issue.ID] {\n\t\tif dep.Type == types.DepParentChild {\n\t\t\tparent = &dep.DependsOnID\n\t\t\tbreak\n\t\t}\n\t}\n\treturn &types.IssueWithCounts{\n\t\tIssue:           issue,\n\t\tDependencyCount: counts.DependencyCount,\n\t\tDependentCount:  counts.DependentCount,","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/uow/ready_claimer.go#L94-L130","documentation":"hydrateReadyRow fetches comment counts for the claimed issue via CommentUseCase().GetCommentCounts and wraps any failure. This is the third hydration step (after dependency counts and records); failing here aborts the claim so a partially hydrated result is never returned to the caller.","triggerScenarios":"ClaimNextInUOW → hydrateReadyRow where GetCommentCounts(ctx, [issueID]) errors — SQL failure, connection loss, or comment use-case error while counting comments for the claimed issue.","commonSituations":"Dolt server error during 'bd ready'; permission problems on comment tables; large comment tables making the count query time out; transient network interruption.","solutions":["Retry the claim/ready command","Inspect the wrapped underlying error (%w) via server logs or verbose output","Check grants on the comments table","Increase timeouts if comment count queries are slow"],"exampleFix":"null","handlingStrategy":"retry","validationCode":"// Go: pre-verify comment counts are computable\n_, err := uw.CommentUseCase().GetCommentCounts(ctx, []string{issueID})\nif err != nil { /* resolve access/perf issues before claiming */ }","typeGuard":"func isCommentCountHydrationError(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"comment counts: \")\n}","tryCatchPattern":"issue, err := ClaimNextInUOW(ctx)\nif isCommentCountHydrationError(err) {\n  // transient: back off and retry once before surfacing\n  time.Sleep(time.Second); issue, err = ClaimNextInUOW(ctx)\n}\nreturn issue, err","preventionTips":["Grant the bd SQL user access to comment tables","Index/maintain comment tables so COUNT queries stay fast on large DBs","Set generous timeouts for count queries under load","Retry transient errors; escalate persistent ones with the %w chain"],"tags":["database","query-error","hydration","comments"],"backgroundTag":"hydration-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}