{"record":{"id":"04b380b3db115473","repo":"gastownhall/beads","slug":"failed-to-get-issue-history-w","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/dolt/history.go","lineNumber":87,"sourceCode":"\trows, err := s.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 history []*issueHistory\n\tfor rows.Next() {\n\t\tvar h issueHistory\n\t\tvar issue types.Issue\n\t\tvar createdAtStr, updatedAtStr sql.NullString // TEXT columns - must parse manually\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\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,\n\t\t\t&pinned, &molType,","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/history.go#L69-L105","documentation":"getIssueHistory queries the dolt_history_issues system table to return an issue's state at each commit. This error wraps any failure of that query — typically a SQL/driver error such as the history table not existing, the database not being a Dolt database, or connection failure. The underlying driver error is chained via %w.","triggerScenarios":"Calling GetIssueHistory/getIssueHistory when the underlying table has no dolt_history_issues view (non-Dolt storage or engine without dolt history), when the query errors due to connectivity/auth failure against the Dolt server, or a syntax/permission error on the SELECT.","commonSituations":"Pointing beads at a MySQL (non-Dolt) server that lacks dolt_history tables; running against an old Dolt engine without dolt_history support; the server connection dropping mid-query; insufficient privileges to read system tables.","solutions":["Inspect the wrapped cause (errors.Unwrap / %w chain) — fix the underlying driver error first (connectivity, auth, permissions).","Confirm the storage backend is actually Dolt and supports dolt_history_issues; dolt history system tables don't exist on plain MySQL.","Upgrade the Dolt server/engine to a version supporting dolt_history_<table> system tables."],"exampleFix":"// before\nh, err := store.GetIssueHistory(ctx, \"bd-123\")\nlog.Println(err) // \"failed to get issue history: ...\" opaque\n// after\nh, err := store.GetIssueHistory(ctx, \"bd-123\")\nif err != nil {\n    log.Printf(\"history query failed: %v\", errors.Unwrap(err)) // see real driver cause\n}","handlingStrategy":"try-catch","validationCode":"var oneRow int\nif err := db.QueryRow(\"SELECT COUNT(*) FROM dolt_history_issues\").Scan(&oneRow); err != nil {\n    return fmt.Errorf(\"history not available on this backend: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"h, err := store.GetIssueHistory(ctx, id)\nif err != nil {\n    var derr *driverErr // or inspect errors.Unwrap chain\n    if errors.As(err, &derr) && strings.Contains(err.Error(), \"doesn't exist\") {\n        return nil, nil // backend lacks dolt history\n    }\n    return fmt.Errorf(\"get issue history: %w\", err)\n}","preventionTips":["Confirm the backend is Dolt (supports dolt_history_* tables) before relying on history APIs.","Check server health/connectivity before long history queries in scripts.","Always log the unwrapped cause to distinguish schema/backend problems from transient failures."],"tags":["dolt","history","query-failed","wrapped-error"],"backgroundTag":"query-execution-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}