gastownhall/beads · error
check staged changes before commit: %w
Error message
check staged changes before commit: %w
What it means
After staging, StageAndCommit calls issueops.HasStagedChanges so DOLT_COMMIT('-m') isn't run against an empty staged set (which would emit a 'nothing to commit' warning); failures in that check are wrapped as 'check staged changes before commit: %w'. Like the pending-changes check, this is a query failure (connection/server issue), not a data problem.
Source
Thrown at internal/storage/versioncontrolops/commit.go:88
if !pending {
return nil
}
for table := range dirtyTables {
if _, err := conn.ExecContext(ctx, "CALL DOLT_ADD(?)", table); err != nil {
return fmt.Errorf("dolt add %s: %w", table, err)
}
}
// Precise guard: HasPendingChanges above is global, but we only DOLT_ADD the
// dirty-tracked tables. When those specific tables turn out clean (idempotent
// no-op) while some UNRELATED table is concurrently dirty, the fast-path does
// not fire yet staging stages nothing — so DOLT_COMMIT('-m') would still emit
// the "nothing to commit" warning. Check the STAGED set (exactly what '-m'
// will commit) and skip the empty commit.
staged, err := issueops.HasStagedChanges(ctx, conn)
if err != nil {
return fmt.Errorf("check staged changes before commit: %w", err)
}
if !staged {
return nil
}
if author == "" {
_, err = conn.ExecContext(ctx, "CALL DOLT_COMMIT('-m', ?)", commitMsg)
} else {
_, err = conn.ExecContext(ctx, "CALL DOLT_COMMIT('-m', ?, '--author', ?)", commitMsg, author)
}
if err != nil && !issueops.IsNothingToCommitError(err) {
return fmt.Errorf("dolt commit: %w", err)
}
return nil
}
View on GitHub (pinned to 71377f2769)
Solutions
- Reconnect and retry StageAndCommit (the operation is idempotent)
- Inspect the wrapped driver error to distinguish connection failure from query/schema failure
- Confirm the Dolt version supports the staging queries used by HasStagedChanges
Example fix
// before
err := versioncontrolops.StageAndCommit(ctx, db, tables, msg, author)
// after
err := versioncontrolops.StageAndCommit(ctx, db, tables, msg, author)
if err != nil && isConnectionError(err) {
db = reconnect(ctx)
err = versioncontrolops.StageAndCommit(ctx, db, tables, msg, author)
} Defensive patterns
Strategy: retry
Validate before calling
if err := conn.PingContext(ctx); err != nil {
return fmt.Errorf("connection unhealthy before staged check: %w", err)
} Try / catch
err := versioncontrolops.StageAndCommit(ctx, conn, tables, msg, author)
if err != nil && strings.Contains(err.Error(), "check staged changes before commit") {
conn = reconnect(ctx)
err = versioncontrolops.StageAndCommit(ctx, conn, tables, msg, author)
} Prevention
- Health-check the connection mid-flow if operations are long-running
- Retry on transient errors; the staged check makes the commit safe to re-run
- Pin a known-good Dolt version in deployments
- Run commit flows on a dedicated session to avoid contention
When it happens
Trigger: Calling StageAndCommit when the HasStagedChanges query fails — connection loss, Dolt server down, or dolt_status staging query unavailable/changed.
Common situations: Long-running process whose connection went stale; embedded Dolt process crash between DOLT_ADD and the staged check; Dolt version where the staged-changes query behaves differently.
Related errors
- check pending changes before commit: %w
- dolt add %s: %w
- failed to stage is_blocked repairs: %w
- failed to stage %s before commit: %w
- dolt commit: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/0d369300df552374.
Report an issue: GitHub.