gastownhall/beads · error
query dolt_status: %w
Error message
query dolt_status: %w
What it means
WorkingSetClean queries the dolt_status table to determine whether the Dolt working set has uncommitted changes. If the SELECT fails — database unavailable, permissions, corrupted repo — the error is wrapped as "query dolt_status: %w" and returned instead of being silently treated as dirty (unlike mergesettle.go which swallows the query error).
Source
Thrown at internal/storage/versioncontrolops/fastforward.go:63
if err := db.QueryRowContext(ctx, query).Scan(&ahead, &behind); err != nil {
return false, fmt.Errorf("compare local HEAD to %s: %w", ref, err)
}
return ahead == 0 && behind >= 1, nil
}
// WorkingSetClean reports whether the Dolt working set has no uncommitted
// changes, EXCLUDING dolt-ignored wisp tables ("wisps" and "wisp_*"), which
// cannot be staged/committed and so should never block a clean-working-set
// gate. This mirrors the exclusion in DirtyTableTracker.MarkDirty
// (commit.go), but — unlike the unexported workingSetClean in
// mergesettle.go, which does not exclude wisps and swallows its query
// error — this reports the error to the caller instead of treating it as
// dirty.
func WorkingSetClean(ctx context.Context, db DBConn) (bool, error) {
rows, err := db.QueryContext(ctx, "SELECT table_name FROM dolt_status")
if err != nil {
return false, fmt.Errorf("query dolt_status: %w", err)
}
defer rows.Close()
clean := true
for rows.Next() {
var table string
if err := rows.Scan(&table); err != nil {
return false, fmt.Errorf("scan dolt_status: %w", err)
}
if table == "wisps" || strings.HasPrefix(table, "wisp_") {
continue
}
clean = false
}
if err := rows.Err(); err != nil {
return false, fmt.Errorf("iterate dolt_status: %w", err)
}
View on GitHub (pinned to 71377f2769)
Solutions
- Inspect the wrapped error; fix the underlying connection/availability problem and retry.
- Confirm you are connected to a Dolt database (dolt_status exists), not a non-Dolt store.
- Restart the Dolt sql-server / re-open the embedded engine, then retry.
- Check privileges for the database user to read system tables.
Example fix
// before
clean, err := versioncontrolops.WorkingSetClean(ctx, db)
// after
if err := db.PingContext(ctx); err != nil {
return fmt.Errorf("dolt unavailable: %w", err)
}
clean, err := versioncontrolops.WorkingSetClean(ctx, db) Defensive patterns
Strategy: try-catch
Validate before calling
if err := db.PingContext(ctx); err != nil {
return fmt.Errorf("dolt not reachable: %w", err)
} Try / catch
clean, err := versioncontrolops.WorkingSetClean(ctx, db)
if err != nil {
if isTransientDBError(err) {
time.Sleep(backoff)
return versioncontrolops.WorkingSetClean(ctx, db)
}
return err // fail closed: do not assume clean or dirty
} Prevention
- Confirm the target is a Dolt database (dolt_status exists) before version-control operations.
- Start the embedded Dolt engine or sql-server before issuing storage queries.
- Fail closed on this error — never treat a query failure as 'working set is dirty' or 'clean'.
When it happens
Trigger: Calling WorkingSetClean(ctx, db) when the Dolt connection is down; the database lacks a dolt_status system table (not a valid Dolt database); the connection has insufficient privileges; context cancelled during query startup.
Common situations: Embedded Dolt engine not started before the call; pointing at a plain MySQL/SQLite database rather than a Dolt database; transient server restart; repo corruption.
Related errors
- failed to begin transaction: %w
- failed to recompute is_blocked: %w
- failed to commit is_blocked repairs: %w
- failed to query orphaned dependencies: %w
- row iteration error: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/6efa464d11235bec.
Report an issue: GitHub.