{"record":{"id":"2f31b25927993307","repo":"gastownhall/beads","slug":"stage-resolved-s-w","errorCode":null,"errorMessage":"stage resolved %s: %w","messagePattern":"stage resolved (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/mergesettle.go","lineNumber":171,"sourceCode":"\t\t\t\treturn &MergeConflictsError{Conflicts: conflicts, MergeErr: mergeErr}\n\t\t\t}\n\t\t\t// #4992 part 2: the operator asked for an escape hatch. Unlike\n\t\t\t// TryAutoResolveMergeConflicts, no allowlist applies — every\n\t\t\t// conflicted table (the resolver pre-screens ALL of them before\n\t\t\t// resolving any, so `resolved == false` means none were touched)\n\t\t\t// is resolved with the named strategy.\n\t\t\tfor _, c := range conflicts {\n\t\t\t\ttable := c.Field\n\t\t\t\tif table == \"\" {\n\t\t\t\t\ttable = \"issues\"\n\t\t\t\t}\n\t\t\t\tif err := ResolveConflicts(ctx, db, table, strategy); err != nil {\n\t\t\t\t\tabortMerge(ctx, db, preMergeClean)\n\t\t\t\t\treturn fmt.Errorf(\"resolve %s conflicts with '%s' strategy: %w\", table, strategy, err)\n\t\t\t\t}\n\t\t\t\tif _, err := db.ExecContext(ctx, \"CALL DOLT_ADD(?)\", table); err != nil {\n\t\t\t\t\tabortMerge(ctx, db, preMergeClean)\n\t\t\t\t\treturn fmt.Errorf(\"stage resolved %s: %w\", table, err)\n\t\t\t\t}\n\t\t\t}\n\t\t\tstrategyResolved = true\n\t\t}\n\t}\n\n\t// bd-6dnrw.4: repair FK cascade violations the merge produced (child rows\n\t// whose parent issue was deleted on the other clone). Unrepaired\n\t// violations MUST NOT survive: with the force flag on, every statement\n\t// autocommits, so the abort below is what keeps them out of the database.\n\t// This also covers violations a strategy resolution left behind (e.g.\n\t// --ours keeps a child row whose parent was deleted on the other side).\n\trepairedViol, hadViol, violErr := TryRepairFKCascadeViolations(ctx, db)\n\tif violErr != nil {\n\t\tabortMerge(ctx, db, preMergeClean)\n\t\tif mergeErr != nil {\n\t\t\treturn mergeErr\n\t\t}","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/mergesettle.go#L153-L189","documentation":"After a strategy resolution succeeds, SettleMerge stages the table with `CALL DOLT_ADD(?)`. \"stage resolved %s: %w\" wraps DOLT_ADD's failure. The resolution itself worked but the resolved file could not be staged, so the merge is aborted and the working set restored rather than committing a half-staged state.","triggerScenarios":"DOLT_ADD failing on a table name (empty Field defaulting to 'issues' not matching the actual conflict table), a Dolt server error, or the merge state having been closed by another session between resolve and add.","commonSituations":"Concurrent bd sessions mutating the same repo mid-merge; Dolt server-side storage errors; conflicts reported on a table whose name DOLT_ADD rejects (quoting/parameter issues in odd Dolt versions).","solutions":["Retry the merge — the abort restored the working set, so a clean retry usually succeeds","Ensure no other bd process operates on the database concurrently during pull/merge","Check the wrapped error for the DOLT_ADD root cause (unknown table, storage error)","Upgrade Dolt if the parameterized CALL DOLT_ADD(?) form is rejected by your version"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure exclusive access before merging\nvar busy int\n_ = db.QueryRowContext(ctx, \"SELECT COUNT(*) FROM information_schema.processlist WHERE db = DATABASE() AND id != CONNECTION_ID()\").Scan(&busy)\nif busy > 0 {\n\treturn errors.New(\"other sessions are using this database; retry when idle\")\n}","typeGuard":"func isStagingFailure(err error) bool { return strings.Contains(err.Error(), \"stage resolved \") }","tryCatchPattern":"err := versioncontrolops.MergeAndSettleWithStrategy(ctx, db, ref, strategy)\nif err != nil && isStagingFailure(err) {\n\t// merge was aborted; working set restored — safe to retry\n\terr = versioncontrolops.MergeAndSettleWithStrategy(ctx, db, ref, strategy)\n}","preventionTips":["Retry once on staging failures — abortMerge restores a clean state","Serialize bd operations; never run concurrent pulls/merges on one clone","Keep the Dolt engine current; parameterized DOLT_ADD quirks vary by version","Check disk/storage health if staging failures repeat"],"tags":["dolt","merge-conflicts","staging"],"backgroundTag":"merge-conflict-resolution-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}