gastownhall/beads · error

failed to get issue history: %w

Error message

failed to get issue history: %w

What it means

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.

Source

Thrown at internal/storage/dolt/history.go:87

	rows, err := s.queryContext(ctx, `
		SELECT
			id, title,
			COALESCE(description, '') AS description,
			COALESCE(design, '') AS design,
			COALESCE(acceptance_criteria, '') AS acceptance_criteria,
			COALESCE(notes, '') AS notes,
			status, priority, issue_type, assignee, owner, created_by,
			estimated_minutes, created_at, updated_at, closed_at, close_reason,
			pinned, mol_type,
			commit_hash, committer, commit_date
		FROM (
			SELECT * FROM dolt_history_issues
		) h
		WHERE h.id = ?
		ORDER BY h.commit_date DESC
	`, issueID)
	if err != nil {
		return nil, fmt.Errorf("failed to get issue history: %w", err)
	}
	defer rows.Close()

	var history []*issueHistory
	for rows.Next() {
		var h issueHistory
		var issue types.Issue
		var createdAtStr, updatedAtStr sql.NullString // TEXT columns - must parse manually
		var closedAt sql.NullTime
		var assignee, owner, createdBy, closeReason, molType sql.NullString
		var estimatedMinutes sql.NullInt64
		var pinned sql.NullInt64

		if err := rows.Scan(
			&issue.ID, &issue.Title, &issue.Description, &issue.Design, &issue.AcceptanceCriteria, &issue.Notes,
			&issue.Status, &issue.Priority, &issue.IssueType, &assignee, &owner, &createdBy,
			&estimatedMinutes, &createdAtStr, &updatedAtStr, &closedAt, &closeReason,
			&pinned, &molType,

View on GitHub (pinned to 71377f2769)

Solutions

  1. Inspect the wrapped cause (errors.Unwrap / %w chain) — fix the underlying driver error first (connectivity, auth, permissions).
  2. Confirm the storage backend is actually Dolt and supports dolt_history_issues; dolt history system tables don't exist on plain MySQL.
  3. Upgrade the Dolt server/engine to a version supporting dolt_history_<table> system tables.

Example fix

// before
h, err := store.GetIssueHistory(ctx, "bd-123")
log.Println(err) // "failed to get issue history: ..." opaque
// after
h, err := store.GetIssueHistory(ctx, "bd-123")
if err != nil {
    log.Printf("history query failed: %v", errors.Unwrap(err)) // see real driver cause
}
Defensive patterns

Strategy: try-catch

Validate before calling

var oneRow int
if err := db.QueryRow("SELECT COUNT(*) FROM dolt_history_issues").Scan(&oneRow); err != nil {
    return fmt.Errorf("history not available on this backend: %w", err)
}

Try / catch

h, err := store.GetIssueHistory(ctx, id)
if err != nil {
    var derr *driverErr // or inspect errors.Unwrap chain
    if errors.As(err, &derr) && strings.Contains(err.Error(), "doesn't exist") {
        return nil, nil // backend lacks dolt history
    }
    return fmt.Errorf("get issue history: %w", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/04b380b3db115473. Report an issue: GitHub.