{"record":{"id":"5f4a4adc160e5d6f","repo":"gastownhall/beads","slug":"iter-issues-hydrate-labels-w","errorCode":null,"errorMessage":"iter issues: hydrate labels: %w","messagePattern":"iter issues: hydrate labels: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/iter_issues.go","lineNumber":84,"sourceCode":"\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}\n\treturn storage.NewSliceIter(issues), nil\n}\n","sourceCodeStart":66,"sourceCodeEnd":98,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/iter_issues.go#L66-L98","documentation":"IterIssues batches label hydration after the main scan: GetLabelsForIssuesFromTableInTx runs on the same transaction (after the cursor is closed, since *sql.Tx is single-connection). If that labels query fails, all fetched issues are discarded and this wrapped error is returned.","triggerScenarios":"Calling IterIssues when the labels table is missing, renamed, or its schema differs from what GetLabelsForIssuesFromTableInTx expects, or the tx connection fails during the label query.","commonSituations":"Databases created before the labels table existed (old versions); manual schema changes; corruption in the labels table; transient connection failure between the two queries.","solutions":["Check the wrapped error (missing table vs unknown column vs connection error)","Run migrations / bd doctor to ensure the labels table exists with the expected schema","Retry on transient failures — the whole IterIssues call is retried atomically","If upgrading from a pre-labels database, follow the documented migration path"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"iter, err := store.IterIssues(ctx, query, filter)\nif err != nil && strings.Contains(err.Error(), \"hydrate labels\") {\n    // labels table issue: retry once, then check schema\n    return retryOrMigrate(err)\n}","preventionTips":["Ensure migrations creating the labels table have run","Retry whole IterIssues calls atomically on transient failure","Check schema after any version change that adds tables"],"tags":["storage","dolt","labels","hydration"],"backgroundTag":"sql-query-execution-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}