gastownhall/beads · error

scan commit: %w

Error message

scan commit: %w

What it means

Log wraps a failed rows.Scan into storage.CommitInfo fields (Hash, Author, Email, Date, Message) as "scan commit: <underlying>". The library throws it because a dolt_log row's column types or names did not match the five expected values. Like the status scan error, this points at Dolt engine schema drift for dolt_log (e.g. different date column type) or an unconvertible/NULL value.

Source

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

	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 == "" {
		return false, nil
	}
	if err := issueops.ValidateRef(commitHash); err != nil {
		return false, nil
	}

	var count int
	err := db.QueryRowContext(ctx, `

View on GitHub (pinned to 71377f2769)

Solutions

  1. Run SELECT commit_hash, committer, email, date, message FROM dolt_log LIMIT 1 manually to see actual types.
  2. Align the Dolt engine/driver versions with the ones the library expects.
  3. If the date column type changed, pin the engine version or adapt CommitInfo scanning at the library level.
  4. Read the wrapped error to identify the offending column and value.

Example fix

// before
// engine maps 'date' to a driver type Scan can't decode into c.Date
rows.Scan(&c.Hash, &c.Author, &c.Email, &c.Date, &c.Message)
// after
// pin the supported Dolt engine version so 'date' decodes as time.Time
rows.Scan(&c.Hash, &c.Author, &c.Email, &c.Date, &c.Message)
Defensive patterns

Strategy: validation

Validate before calling

// verify dolt_log column shape before scanning
rows, err := db.QueryContext(ctx, "SELECT commit_hash, committer, email, date, message FROM dolt_log LIMIT 1")
if err != nil { return fmt.Errorf("dolt_log incompatible: %w", err) }
cols, _ := rows.Columns()
rows.Close()
want := []string{"commit_hash", "committer", "email", "date", "message"}
if !reflect.DeepEqual(cols, want) { return fmt.Errorf("dolt_log columns drifted: %v", cols) }

Try / catch

commits, err := versioncontrolops.Log(ctx, db, limit)
if err != nil && strings.HasPrefix(err.Error(), "scan commit") {
    return nil, fmt.Errorf("dolt_log row shape mismatch — check engine version: %w", err)
}

Prevention

When it happens

Trigger: Engine version where dolt_log columns differ (e.g. date returned as a type the driver maps to something Scan can't put into CommitInfo.Date); NULL in a NOT-NULL-assumed column; driver type-mapping incompatibility.

Common situations: Engine upgrade changing dolt_log's date/email column types; a commit with missing committer metadata from an unusual producer; mismatched go-sql-driver version.

Related errors


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