{"record":{"id":"c32fb86feb27590f","repo":"gastownhall/beads","slug":"failed-to-stage-s-before-commit-w","errorCode":null,"errorMessage":"failed to stage %s before commit: %w","messagePattern":"failed to stage (.+?) before commit: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/store.go","lineNumber":3114,"sourceCode":"\t}\n\n\tif len(tables) == 0 {\n\t\t// A merge resolution with a clean working set is NOT a no-op: it is\n\t\t// the `--ours` case, where our values already stood and resolving the\n\t\t// conflict dirtied nothing. Returning here left is_merging true while\n\t\t// the caller reported \"Merge committed\", and the next pull re-wedged\n\t\t// on the unconcluded merge (wy-36ilm, caught by the F9 integration\n\t\t// test). Only the merge-conclusion mode takes this path: for the\n\t\t// other modes an empty working set really is nothing to commit.\n\t\tif mode == configIncludeAll {\n\t\t\treturn s.concludeOpenMerge(ctx, conn, message)\n\t\t}\n\t\treturn nil // Nothing to commit (all changes were config-only or dolt_ignore'd)\n\t}\n\n\tfor _, table := range tables {\n\t\tif err := schema.DrainCall(ctx, conn, \"CALL DOLT_ADD(?)\", table); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to stage %s before commit: %w\", table, err)\n\t\t}\n\t}\n\n\t// NOTE: In SQL procedure mode, Dolt defaults author to the authenticated SQL user\n\t// (e.g. root@localhost). Always pass an explicit author for deterministic history.\n\tif err := schema.DrainCall(ctx, conn, \"CALL DOLT_COMMIT('-m', ?, '--author', ?)\", message, s.commitAuthorString()); err != nil {\n\t\tif isDoltNothingToCommit(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn s.wrapDoltPublicationFailure(ctx, \"failed to commit\", err)\n\t}\n\n\treturn nil\n}\n\n// commitWorkingSetAfterSQLCommit preserves the no-replay boundary for a Dolt\n// publication that follows an already-visible SQL mutation. commitWorkingSet\n// classifies DOLT_COMMIT response loss itself; this wrapper adds the same","sourceCodeStart":3096,"sourceCodeEnd":3132,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/store.go#L3096-L3132","documentation":"Once dirty tables are discovered, each is staged with CALL DOLT_ADD(?) via schema.DrainCall before DOLT_COMMIT runs. This error wraps a failure of that stored-procedure call for a specific table (the %s names it). The commit did not complete; the failure happened mid-staging, so the Dolt working set may have some tables staged.","triggerScenarios":"DOLT_ADD fails for one table: the table was dropped/renamed between discovery and staging, a dolt_ignore rule conflicts, the session hit an error from a prior call, or the procedure returned an error row that DrainCall surfaces.","commonSituations":"Concurrent operations (another bd process committing/checking out) changing table presence mid-commit; GH#2455-style races with stale config rows; schema migrations removing tables while a commit is in flight.","solutions":["Re-run the commit; dolt_status is re-queried so the stale table drops out of the staging list.","Check for concurrent bd processes/sync jobs operating on the same repo and serialize them (file lock or single writer).","Verify the named table still exists (SHOW TABLES) and is not blocked by a dolt_ignore rule.","If DOLT_ADD keeps failing, inspect Dolt session state (dolt_status in a SQL shell) and retry on a fresh connection."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// confirm the repo is quiescent before committing\n// e.g. acquire your own single-writer lock; verify table exists:\n// SHOW TABLES LIKE '<table>'","typeGuard":null,"tryCatchPattern":"err := store.Commit(ctx, msg)\nif err != nil && strings.Contains(err.Error(), \"failed to stage\") {\n\t// safe to re-run: dolt_status is re-queried next attempt\n\ttime.Sleep(time.Second); return store.Commit(ctx, msg)\n}","preventionTips":["Prevent concurrent bd writers on the same repo (single-writer lock or one sync job).","Re-run the commit after races — staging restarts cleanly.","Avoid schema changes (drop/rename) while a commit is in flight.","Review dolt_ignore rules if a target table is being skipped."],"tags":["go","dolt","commit","staging","race"],"backgroundTag":"dolt-stage-before-commit-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}