gastownhall/beads · error

db: ListRemotes: rows: %w

Error message

db: ListRemotes: rows: %w

What it means

This error is returned by ListRemotes after iterating rows, when rows.Err() reports an error encountered during iteration (e.g. the connection dropped or the query was aborted mid-result-set). The scan of earlier rows succeeded, but the full result was not retrieved.

Source

Thrown at internal/storage/domain/db/remote.go:54

}

func (r *remoteSQLRepositoryImpl) ListRemotes(ctx context.Context) ([]domain.Remote, error) {
	rows, err := r.runner.QueryContext(ctx, "SELECT name, url FROM dolt_remotes")
	if err != nil {
		return nil, fmt.Errorf("db: ListRemotes: query: %w", err)
	}
	defer rows.Close()

	var remotes []domain.Remote
	for rows.Next() {
		var rem domain.Remote
		if err := rows.Scan(&rem.Name, &rem.URL); err != nil {
			return nil, fmt.Errorf("db: ListRemotes: scan: %w", err)
		}
		remotes = append(remotes, rem)
	}
	if err := rows.Err(); err != nil {
		return nil, fmt.Errorf("db: ListRemotes: rows: %w", err)
	}
	return remotes, nil
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped cause after 'rows:' for the driver error
  2. Retry ListRemotes with a fresh context if the cause is transient (connection reset, deadline exceeded)
  3. Increase the context timeout when listing against a slow/remote SQL server
  4. Check server logs for aborted connections around the failure time

Example fix

// before
ctx := context.Background()
remotes, err := store.ListRemotes(ctx)
// after
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
remotes, err := store.ListRemotes(ctx)
if err != nil && isTransient(err) { remotes, err = store.ListRemotes(ctx) }
Defensive patterns

Strategy: retry

Validate before calling

ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel() // generous timeout avoids mid-iteration aborts

Type guard

func isRowsErr(err error) bool {
    return err != nil && strings.Contains(err.Error(), "ListRemotes: rows:")
}

Try / catch

var remotes []domain.Remote
var err error
for i := 0; i < 3; i++ {
    remotes, err = store.ListRemotes(ctx)
    if err == nil || !isTransient(err) { break }
    time.Sleep(backoff(i))
}

Prevention

When it happens

Trigger: Calling ListRemotes when the database connection fails or the context is cancelled while streaming rows from the dolt_remotes query — any driver-level error surfaced only via rows.Err() after Next() returns false.

Common situations: Long-lived result set interrupted by network blip to the SQL server; context timeout expiring while listing many remotes; Dolt server killed mid-query.

Related errors


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