{"record":{"id":"2106a14e71cdfc93","repo":"gastownhall/beads","slug":"failed-to-stage-is-blocked-repairs-w","errorCode":null,"errorMessage":"failed to stage is_blocked repairs: %w","messagePattern":"failed to stage is_blocked repairs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/doctor/fix/blocked.go","lineNumber":86,"sourceCode":"\t\treturn fmt.Errorf(\"failed to recompute is_blocked: %w\", err)\n\t}\n\tif err := tx.Commit(); err != nil {\n\t\treturn fmt.Errorf(\"failed to commit is_blocked repairs: %w\", err)\n\t}\n\n\tif changed == 0 {\n\t\tfmt.Println(\"  is_blocked already consistent — nothing to fix\")\n\t\treturn nil\n\t}\n\n\t// Persist the corrected flags as a Dolt commit, staging only issues — the\n\t// synced table is_blocked lives on (wisps are dolt_ignore'd). This path keeps\n\t// its own fresh-DB lifecycle rather than the shared store helper, but it must\n\t// not report success on a failed commit: a swallowed DOLT_COMMIT error would\n\t// leave the repair in the working set only, silently undone by the next pull.\n\t// bd doctor is server-mode only, so the server supplies the commit identity.\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_ADD(?)\", \"issues\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to stage is_blocked repairs: %w\", err)\n\t}\n\tif _, err := db.ExecContext(ctx, \"CALL DOLT_COMMIT('-m', 'doctor: recompute is_blocked for all issues')\"); err != nil && !issueops.IsNothingToCommitError(err) {\n\t\treturn fmt.Errorf(\"failed to commit is_blocked repairs to Dolt: %w\", err)\n\t}\n\n\tfmt.Printf(\"  Recomputed is_blocked: %d row(s) corrected\\n\", changed)\n\treturn nil\n}\n","sourceCodeStart":68,"sourceCodeEnd":95,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/doctor/fix/blocked.go#L68-L95","documentation":"After the transaction commits, repairBlockedState stages the issues table with CALL DOLT_ADD('issues') so the corrected is_blocked flags become a Dolt commit that syncs. This error wraps a failed DOLT_ADD — the repairs exist only in the Dolt working set and will not sync; if left unstaged they could be wiped by the next pull. The function treats this as fatal so success is never reported for an uncommitted repair.","triggerScenarios":"Calling fix.RecomputeBlocked when `CALL DOLT_ADD(?)` with 'issues' fails: the issues table is dolt_ignore'd or not a tracked table in this repo, the Dolt working-set state is inconsistent (e.g. a merge/conflict state left by a crashed sync), the session lost its database context, or the wrapped SQL call itself errored on the server.","commonSituations":"A previous bd sync/pull crashed leaving the Dolt repo mid-merge, so DOLT_ADD refuses to stage; the database was re-initialized so 'issues' is not the expected tracked table name; server version mismatch where DOLT_ADD stored-procedure signatures differ; repo state where issues lives under a different table name than the doctor fix assumes.","solutions":["Check the wrapped %w cause; if the Dolt repo is in a conflicted/merge state, resolve it (`dolt status`, resolve conflicts, `dolt add`/commit or abort the merge) and rerun the fix.","Verify the issues table exists and is tracked: `dolt sql -q \"select count(*) from issues\"` and `dolt status` inside .beads/dolt; re-stage manually with `dolt add issues` if the working set holds the corrections.","Confirm server/version compatibility — ensure the running dolt sql-server supports CALL DOLT_ADD with a bind parameter (upgrade an outdated server).","Rerun `bd doctor --fix` after repairing repo state; then verify with `dolt log` that a 'doctor: recompute is_blocked for all issues' commit lands and `bd dolt push` succeeds."],"exampleFix":"// before (repo stuck mid-merge)\nerr: failed to stage is_blocked repairs: working set has conflicts\n\n// after: clear the merge state first, then retry\n// dolt abort-merge (in .beads/dolt) or resolve conflicts, then:\nif err := fix.RecomputeBlocked(\".\"); err != nil {\n\tlog.Fatalf(\"blocked-state fix failed: %v\", err)\n}","handlingStrategy":"try-catch","validationCode":"// Verify the Dolt repo is in a clean, non-merge state and issues is tracked\nout, err := exec.Command(\"dolt\", \"status\", \"--json\").Output()\nif err != nil || bytes.Contains(out, []byte(\"conflict\")) || bytes.Contains(out, []byte(\"merge\")) {\n\tlog.Fatal(\"dolt working set dirty/conflicted — resolve before blocked-state fix\")\n}","typeGuard":"func canStageIssues(ctx context.Context, db *sql.DB) bool {\n\tvar n int\n\terr := db.QueryRowContext(ctx,\n\t\t\"SELECT COUNT(*) FROM dolt_status WHERE `table` = 'issues'\").Scan(&n)\n\treturn err == nil // issues table present in repo status\n}","tryCatchPattern":"if err := fix.RecomputeBlocked(path); err != nil && strings.Contains(err.Error(), \"failed to stage is_blocked repairs\") {\n\t// repairs sit in the working set only; resolve dolt state, then re-run\n\t// (or manually: dolt add issues && dolt commit -m \"doctor: recompute is_blocked\")\n\tlog.Printf(\"staging failed, working set holds uncommitted repairs: %v\", err)\n}","preventionTips":["Never leave the Dolt repo mid-merge — resolve conflicts after every sync before running doctor --fix","Run bd doctor --fix last in a clean working tree, right after dependency-graph fixes","After a staging failure, do not pull/sync until the issues repairs are committed or rolled back","Keep the dolt sql-server version current so DOLT_ADD stored procedures behave as expected","Verify with `dolt log` that the 'doctor: recompute is_blocked' commit exists after the fix"],"tags":["go","dolt","sql","version-control","staging"],"backgroundTag":"dolt-add-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}