{"record":{"id":"ec83938c1a40cddc","repo":"gastownhall/beads","slug":"iter-issues-scan-w","errorCode":null,"errorMessage":"iter issues: scan: %w","messagePattern":"iter issues: scan: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/iter_issues.go","lineNumber":71,"sourceCode":"\t\tlimitSQL = fmt.Sprintf(\" LIMIT %d\", filter.Limit)\n\t}\n\n\t//nolint:gosec // G201: whereSQL contains column comparisons with ?, limitSQL is a safe integer\n\tq := fmt.Sprintf(`SELECT %s FROM issues %s %s ORDER BY priority ASC, created_at DESC, id ASC%s`,\n\t\tissueops.IssueSelectColumns, sqlbuild.LeaseJoin(\"issues\"), whereSQL, limitSQL)\n\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}","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/iter_issues.go#L53-L89","documentation":"IterIssues failed while scanning one row of the issues SELECT into a types.Issue via issueops.ScanIssueFrom. Materialization stops immediately and the read transaction is rolled back; no iterator is returned to the caller.","triggerScenarios":"A row whose columns don't match ScanIssueFrom expectations: NULL in a non-nullable target, wrong column ordering after IssueSelectColumns/schema mismatch, or value conversion failure (e.g. malformed timestamp).","commonSituations":"Schema drift between binary and database version; rows written by a different beads version; manual edits to the issues table; corrupted row data in Dolt.","solutions":["Check the wrapped error to find which column failed to scan","Run migrations / bd doctor to fix schema-version mismatch","Identify and repair or export-rebuild the offending row(s)","Upgrade or downgrade beads so the scanner matches the on-disk schema"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify schema version compatibility before scanning large result sets\n// (run bd doctor or equivalent schema check at startup)","typeGuard":null,"tryCatchPattern":"iter, err := store.IterIssues(ctx, query, filter)\nif err != nil && strings.Contains(err.Error(), \"scan:\") {\n    // schema/data mismatch: surface for migration or repair\n    return fmt.Errorf(\"database schema may be outdated: %w\", err)\n}","preventionTips":["Apply migrations immediately after upgrading beads","Never hand-edit database rows or schema","Validate a small query after upgrade before bulk operations"],"tags":["storage","dolt","sql-scan","schema-mismatch"],"backgroundTag":"sql-row-scan-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}