gastownhall/beads · error
get status: %w
Error message
get status: %w
What it means
Status wraps a failed query "SELECT table_name, staged, status FROM dolt_status" as "get status: <underlying>". The library throws it because reading the Dolt working set (the dolt_status system table) failed at the SQL level before any rows were scanned. Typically the database is not a Dolt database, the working set is unreadable, or the underlying connection/context failed.
Source
Thrown at internal/storage/versioncontrolops/version_control.go:20
import (
"context"
"fmt"
"regexp"
"strings"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/storage/issueops"
)
// validTablePattern matches valid SQL table names (letters, digits, underscores).
var validTablePattern = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_]*$`)
// Status returns the current Dolt working set status (staged and unstaged changes).
func Status(ctx context.Context, db DBConn) (*storage.Status, error) {
rows, err := db.QueryContext(ctx, "SELECT table_name, staged, status FROM dolt_status")
if err != nil {
return nil, fmt.Errorf("get status: %w", err)
}
defer rows.Close()
status := &storage.Status{
Staged: make([]storage.StatusEntry, 0),
Unstaged: make([]storage.StatusEntry, 0),
}
for rows.Next() {
var tableName string
var staged bool
var statusStr string
if err := rows.Scan(&tableName, &staged, &statusStr); err != nil {
return nil, fmt.Errorf("scan status: %w", err)
}
entry := storage.StatusEntry{Table: tableName, Status: statusStr}
if staged {
status.Staged = append(status.Staged, entry)View on GitHub (pinned to 71377f2769)
Solutions
- Verify the target database is Dolt-initialized (dolt_status exists) — run any Dolt query like SELECT 1 FROM dolt_status LIMIT 1 to confirm.
- If the working set is corrupt, run the engine's repair path (re-init Dolt in that directory or restore repo_state.json from a backup).
- Check connection health and retry; cancel/timeout of ctx produces this too.
- Inspect the wrapped error message for driver-specific causes (unknown table vs. connection refused) and fix accordingly.
Example fix
// before rows, err := db.QueryContext(ctx, "SELECT table_name, staged, status FROM dolt_status") // plain MySQL db, no dolt_status // after // initialize the db as a Dolt database first: // dolt init (or ensure the embedded engine opened a dolt-initialized directory) rows, err := db.QueryContext(ctx, "SELECT table_name, staged, status FROM dolt_status")
Defensive patterns
Strategy: type-guard
Validate before calling
// confirm the target is a Dolt database before calling Status
if _, err := db.QueryContext(ctx, "SELECT 1 FROM dolt_status LIMIT 1"); err != nil {
return fmt.Errorf("not a Dolt-initialized database: %w", err)
} Type guard
func isDoltReady(ctx context.Context, db DBConn) bool {
rows, err := db.QueryContext(ctx, "SELECT 1 FROM dolt_status LIMIT 1")
if err != nil { return false }
rows.Close()
return true
} Try / catch
st, err := versioncontrolops.Status(ctx, db)
if err != nil {
if strings.Contains(err.Error(), "get status") && strings.Contains(err.Error(), "dolt_status") {
return fmt.Errorf("database is not Dolt-initialized: %w", err)
}
if errors.Is(err, context.DeadlineExceeded) { return retryLater }
return err
} Prevention
- Never point bd at a plain MySQL schema; ensure the directory was dolt-initialized.
- Check connection health (ping) before status calls after an engine restart.
- Set sane ctx deadlines so cancellations surface as timeouts, not half-read states.
- If dolt_status becomes unreadable, suspect a corrupt working set and restore repo_state.json from backup rather than retrying blindly.
When it happens
Trigger: Calling Status against a database that lacks the dolt_status table (non-Dolt or not a Dolt-initialized schema); the Dolt engine cannot read the working set (corrupt repo_state / working-set file); the context is cancelled or the connection drops mid-query.
Common situations: Pointing bd at a plain MySQL/Dolt-SQL-server database that was never dolt-initialized; running status while another process holds a corrupted working set; stale connection after the embedded engine restarted.
Related errors
- failed to query dolt_status: %w
- descendants: query: %w
- db: ListRemotes: query: %w
- list branches: %w
- query dependency conflicts: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/d8eed1103cb59a2d.
Report an issue: GitHub.