{"record":{"id":"6efa464d11235bec","repo":"gastownhall/beads","slug":"query-dolt-status-w","errorCode":null,"errorMessage":"query dolt_status: %w","messagePattern":"query dolt_status: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/fastforward.go","lineNumber":63,"sourceCode":"\tif err := db.QueryRowContext(ctx, query).Scan(&ahead, &behind); err != nil {\n\t\treturn false, fmt.Errorf(\"compare local HEAD to %s: %w\", ref, err)\n\t}\n\n\treturn ahead == 0 && behind >= 1, nil\n}\n\n// WorkingSetClean reports whether the Dolt working set has no uncommitted\n// changes, EXCLUDING dolt-ignored wisp tables (\"wisps\" and \"wisp_*\"), which\n// cannot be staged/committed and so should never block a clean-working-set\n// gate. This mirrors the exclusion in DirtyTableTracker.MarkDirty\n// (commit.go), but — unlike the unexported workingSetClean in\n// mergesettle.go, which does not exclude wisps and swallows its query\n// error — this reports the error to the caller instead of treating it as\n// dirty.\nfunc WorkingSetClean(ctx context.Context, db DBConn) (bool, error) {\n\trows, err := db.QueryContext(ctx, \"SELECT table_name FROM dolt_status\")\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"query dolt_status: %w\", err)\n\t}\n\tdefer rows.Close()\n\n\tclean := true\n\tfor rows.Next() {\n\t\tvar table string\n\t\tif err := rows.Scan(&table); err != nil {\n\t\t\treturn false, fmt.Errorf(\"scan dolt_status: %w\", err)\n\t\t}\n\t\tif table == \"wisps\" || strings.HasPrefix(table, \"wisp_\") {\n\t\t\tcontinue\n\t\t}\n\t\tclean = false\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn false, fmt.Errorf(\"iterate dolt_status: %w\", err)\n\t}\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/fastforward.go#L45-L81","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nclean, err := versioncontrolops.WorkingSetClean(ctx, db)\n// after\nif err := db.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"dolt unavailable: %w\", err)\n}\nclean, err := versioncontrolops.WorkingSetClean(ctx, db)","handlingStrategy":"try-catch","validationCode":"if err := db.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"dolt not reachable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"clean, err := versioncontrolops.WorkingSetClean(ctx, db)\nif err != nil {\n    if isTransientDBError(err) {\n        time.Sleep(backoff)\n        return versioncontrolops.WorkingSetClean(ctx, db)\n    }\n    return err // fail closed: do not assume clean or dirty\n}","preventionTips":["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'."],"tags":["dolt","sql","database","working-set"],"backgroundTag":"dolt-status-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}