gastownhall/beads · error

get log: %w

Error message

get log: %w

What it means

Log wraps a failed query against dolt_log (with or without LIMIT ?) as "get log: <underlying>". The library throws it because the commit-history query failed before rows were returned. dolt_log only exists in a Dolt database with at least one commit, so the most common causes are a non-Dolt/uninitialized database or a connection/context failure.

Source

Thrown at internal/storage/versioncontrolops/version_control.go:59

		}
	}
	return status, rows.Err()
}

// Log returns recent commit history up to limit entries.
// If limit is 0 or negative, all entries are returned.
func Log(ctx context.Context, db DBConn, limit int) ([]storage.CommitInfo, error) {
	var query string
	var args []interface{}
	if limit > 0 {
		query = "SELECT commit_hash, committer, email, date, message FROM dolt_log ORDER BY date DESC LIMIT ?"
		args = []interface{}{limit}
	} else {
		query = "SELECT commit_hash, committer, email, date, message FROM dolt_log ORDER BY date DESC"
	}
	rows, err := db.QueryContext(ctx, query, args...)
	if err != nil {
		return nil, fmt.Errorf("get log: %w", err)
	}
	defer rows.Close()

	var commits []storage.CommitInfo
	for rows.Next() {
		var c storage.CommitInfo
		if err := rows.Scan(&c.Hash, &c.Author, &c.Email, &c.Date, &c.Message); err != nil {
			return nil, fmt.Errorf("scan commit: %w", err)
		}
		commits = append(commits, c)
	}
	return commits, rows.Err()
}

// CommitExists checks whether a commit hash (or prefix) exists in dolt_log.
// Returns false for empty strings or malformed input.
func CommitExists(ctx context.Context, db DBConn, commitHash string) (bool, error) {
	if commitHash == "" {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Confirm the database has commit history: SELECT COUNT(*) FROM dolt_log — if the table is missing, the db was never Dolt-initialized; run dolt init / make an initial commit.
  2. Verify you are pointed at the intended database directory/schema.
  3. Reconnect (recycle the stale connection) and retry; check ctx deadlines.
  4. Inspect the wrapped error for unknown-table vs. connection errors and address the specific cause.

Example fix

// before
commits, err := versioncontrolops.Log(ctx, db, 10) // fresh db, no dolt_log
// after
// make the first commit so dolt_log exists:
// dolt add -A && dolt commit -m "init"
commits, err := versioncontrolops.Log(ctx, db, 10)
Defensive patterns

Strategy: validation

Validate before calling

// ensure the db has commit history before requesting the log
var n int
if err := db.QueryRowContext(ctx, "SELECT COUNT(*) FROM dolt_log").Scan(&n); err != nil {
    return fmt.Errorf("no dolt_log (initialize the Dolt database first): %w", err)
}
_ = n

Type guard

func hasCommitHistory(ctx context.Context, db DBConn) bool {
    var n int
    return db.QueryRowContext(ctx, "SELECT COUNT(*) FROM dolt_log").Scan(&n) == nil
}

Try / catch

commits, err := versioncontrolops.Log(ctx, db, limit)
if err != nil {
    if strings.Contains(err.Error(), "get log") && strings.Contains(err.Error(), "dolt_log") {
        return nil, fmt.Errorf("database has no commit history; run dolt init + first commit")
    }
    return nil, err
}

Prevention

When it happens

Trigger: Calling Log on a database with no commits (fresh, uninitialized dolt dir) so dolt_log is missing or empty-erroring; querying a non-Dolt schema; ctx cancelled or connection reset mid-query.

Common situations: Running bd vc log right after creating a database that has never had a Dolt commit; pointing at the wrong database/directory; embedded engine restart dropping the connection.

Related errors


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