{"record":{"id":"7a9c351eddf312e9","repo":"gastownhall/beads","slug":"iter-issues-rows-w","errorCode":null,"errorMessage":"iter issues: rows: %w","messagePattern":"iter issues: rows: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/iter_issues.go","lineNumber":77,"sourceCode":"\n\tvar issues []*types.Issue\n\ttxErr := s.withReadTx(ctx, func(tx *sql.Tx) error {\n\t\trows, err := tx.QueryContext(ctx, q, args...)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"iter issues: query: %w\", err)\n\t\t}\n\t\tdefer func() { _ = rows.Close() }()\n\t\tids := make([]string, 0)\n\t\tfor rows.Next() {\n\t\t\tiss, scanErr := issueops.ScanIssueFrom(rows)\n\t\t\tif scanErr != nil {\n\t\t\t\treturn fmt.Errorf(\"iter issues: scan: %w\", scanErr)\n\t\t\t}\n\t\t\tissues = append(issues, iss)\n\t\t\tids = append(ids, iss.ID)\n\t\t}\n\t\tif err := rows.Err(); err != nil {\n\t\t\treturn fmt.Errorf(\"iter issues: rows: %w\", err)\n\t\t}\n\t\t// A *sql.Tx is bound to one connection, so the cursor must be closed\n\t\t// before the label query can run on it (idempotent with the defer).\n\t\t_ = rows.Close()\n\t\tlabelMap, err := issueops.GetLabelsForIssuesFromTableInTx(ctx, tx, \"labels\", ids)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"iter issues: hydrate labels: %w\", err)\n\t\t}\n\t\tfor _, iss := range issues {\n\t\t\tif labels, ok := labelMap[iss.ID]; ok {\n\t\t\t\tiss.Labels = labels\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\tif txErr != nil {\n\t\treturn nil, txErr\n\t}","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/iter_issues.go#L59-L95","documentation":"After scanning all rows, IterIssues calls rows.Err() to detect deferred iteration errors from the driver (connection loss, context cancellation mid-scan). If the result stream itself failed, the whole materialization is abandoned and this wrapped error is returned.","triggerScenarios":"Calling IterIssues when the connection drops or the context is cancelled while rows are being streamed inside withReadTx, so the scan loop completed but the driver reports an error at rows.Err().","commonSituations":"Slow/large queries hitting context deadline; Dolt server restart or network drop mid-query; connection pool exhaustion causing the tx connection to be reclaimed.","solutions":["Increase the context timeout or remove early cancellation for large iterations","Retry the call — transient connection drops are often recoverable","Check Dolt server health/logs for the underlying transport error","Paginate via filters/limits if result sets are very large"],"exampleFix":"// before\ntissues, err := store.IterIssues(ctx, \"\", types.IssueFilter{})\n\n// after: generous timeout for large exports\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\ntissues, err := store.IterIssues(ctx, \"\", types.IssueFilter{})","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"var iter storage.Iter[types.Issue]\nerr := retryWithBackoff(3, func() error {\n    var e error\n    iter, e = store.IterIssues(ctx, query, filter)\n    return e\n})\nif err != nil { return err }","preventionTips":["Use generous context timeouts for large iterations","Avoid cancelling contexts mid-iteration","Monitor Dolt server stability for long-running exports"],"tags":["storage","dolt","rows-iteration","connection"],"backgroundTag":"rows-iteration-error","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}