{"record":{"id":"ffb585b920bacf87","repo":"gastownhall/beads","slug":"failed-to-get-issue-history-w-ffb585","errorCode":null,"errorMessage":"failed to get issue history: %w","messagePattern":"failed to get issue history: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/history.go","lineNumber":38,"sourceCode":"\trows, err := tx.QueryContext(ctx, `\n\t\tSELECT\n\t\t\tid, title,\n\t\t\tCOALESCE(description, '') AS description,\n\t\t\tCOALESCE(design, '') AS design,\n\t\t\tCOALESCE(acceptance_criteria, '') AS acceptance_criteria,\n\t\t\tCOALESCE(notes, '') AS notes,\n\t\t\tstatus, priority, issue_type, assignee, owner, created_by,\n\t\t\testimated_minutes, created_at, updated_at, closed_at, close_reason,\n\t\t\tpinned, mol_type,\n\t\t\tcommit_hash, committer, commit_date\n\t\tFROM (\n\t\t\tSELECT * FROM dolt_history_issues\n\t\t) h\n\t\tWHERE h.id = ?\n\t\tORDER BY h.commit_date DESC\n\t`, issueID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get issue history: %w\", err)\n\t}\n\tdefer rows.Close()\n\n\tvar entries []*storage.HistoryEntry\n\tfor rows.Next() {\n\t\tvar issue types.Issue\n\t\tvar createdAtStr, updatedAtStr sql.NullString\n\t\tvar closedAt sql.NullTime\n\t\tvar assignee, owner, createdBy, closeReason, molType sql.NullString\n\t\tvar estimatedMinutes sql.NullInt64\n\t\tvar pinned sql.NullInt64\n\t\tvar commitHash, committer string\n\t\tvar commitDate time.Time\n\n\t\tif err := rows.Scan(\n\t\t\t&issue.ID, &issue.Title, &issue.Description, &issue.Design, &issue.AcceptanceCriteria, &issue.Notes,\n\t\t\t&issue.Status, &issue.Priority, &issue.IssueType, &assignee, &owner, &createdBy,\n\t\t\t&estimatedMinutes, &createdAtStr, &updatedAtStr, &closedAt, &closeReason,","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/history.go#L20-L56","documentation":"HistoryInTx queries the Dolt system table dolt_history_issues for all historical commits touching an issue and the query failed. The wrapper is contextual; the wrapped error indicates why the history query failed (missing history table, bad SQL, connection issue).","triggerScenarios":"Calling the history API (bd history/log of an issue) when the SELECT ... FROM dolt_history_issues WHERE h.id = ? ... fails — dolt_history_issues unavailable (non-Dolt backend or very old schema), malformed query against a changed schema, or DB error.","commonSituations":"Running history commands against a non-Dolt (SQLite) backend that lacks dolt_history_* tables; issue ID that doesn't exist combined with driver quirks; Dolt server upgrade changing history table columns; connection drops during large history scans.","solutions":["Confirm the backend is Dolt — dolt_history_issues only exists in Dolt databases; use a Dolt-backed database for history features.","Read the wrapped error: 'no such table dolt_history_issues' → wrong backend or outdated schema; run migrations or use a Dolt DB.","Verify the issue ID exists (bd show <id>) — history of a never-committed ID may error depending on backend.","Retry on transient connection errors; check dolt sql-server health and logs."],"exampleFix":"// before: calling history against SQLite backend\nentries, err := store.History(ctx, \"PROJ-1\") // no dolt_history_issues in sqlite\n// after: guard on backend capability\nif !store.SupportsHistory() { return fmt.Errorf(\"history requires a Dolt-backed database\") }\nentries, err := store.History(ctx, \"PROJ-1\")","handlingStrategy":"type-guard","validationCode":"func supportsHistory(tx DBTX) bool {\n    var n int\n    err := tx.QueryRowContext(context.Background(),\n        \"SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 'dolt_history_issues'\").Scan(&n)\n    return err == nil && n > 0\n}","typeGuard":"func isHistoryUnavailable(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"dolt_history_issues\")\n}","tryCatchPattern":"entries, err := store.HistoryInTx(ctx, tx, issueID)\nif err != nil {\n    if isHistoryUnavailable(err) {\n        return nil, fmt.Errorf(\"history requires a Dolt-backed database (got %T)\", store.Driver())\n    }\n    return nil, err\n}","preventionTips":["Verify the backend is Dolt before exposing history features in tooling.","Check the issue ID exists (bd show) before requesting its history.","Keep the Dolt server and bd versions in sync so history table schemas match.","Retry transient connection errors during large history scans."],"tags":["database","dolt","history","go"],"backgroundTag":"missing-history-table","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}