{"record":{"id":"8d88d66ae590cce0","repo":"gastownhall/beads","slug":"merge-branch-s-w","errorCode":null,"errorMessage":"merge branch %s: %w","messagePattern":"merge branch (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/mergesettle.go","lineNumber":288,"sourceCode":"\t}\n\tif _, err := db.ExecContext(ctx, \"SET @@dolt_force_transaction_commit = 1\"); err != nil {\n\t\treturn nil, fmt.Errorf(\"set dolt_force_transaction_commit: %w\", err)\n\t}\n\n\t_, mergeErr := db.ExecContext(ctx, \"CALL DOLT_MERGE('--author', ?, ?)\", author, ref)\n\tif mergeErr != nil && strings.Contains(mergeErr.Error(), \"up to date\") {\n\t\tmergeErr = nil\n\t}\n\n\t// Check for conflicts regardless of whether the merge statement itself\n\t// errored: with the flags above set, a genuinely conflicted merge lands in\n\t// the working set instead of erroring, but older Dolt behavior (or a\n\t// conflict class the flags don't cover) may still report both.\n\tconflicts, cErr := GetConflicts(ctx, db)\n\tif cErr != nil {\n\t\tabortMerge(ctx, db, preMergeClean)\n\t\tif mergeErr != nil {\n\t\t\treturn nil, fmt.Errorf(\"merge branch %s: %w\", ref, mergeErr)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"check merge conflicts for branch %s: %w\", ref, cErr)\n\t}\n\n\tif len(conflicts) == 0 {\n\t\tif mergeErr != nil {\n\t\t\t// Not a conflict: some other merge failure (unknown branch, dirty\n\t\t\t// working set, ...). Nothing to resolve — surface it as-is.\n\t\t\tabortMerge(ctx, db, preMergeClean)\n\t\t\treturn nil, fmt.Errorf(\"merge branch %s: %w\", ref, mergeErr)\n\t\t}\n\t\treturn nil, nil\n\t}\n\n\tdirtyTables := make(map[string]bool, len(conflicts))\n\tfor _, c := range conflicts {\n\t\ttable := c.Field\n\t\tif table == \"\" {","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/mergesettle.go#L270-L306","documentation":"MergeWithStrategy ran CALL DOLT_MERGE and got a non-conflict error (mergeErr), and while inspecting, GetConflicts also failed (cErr). Since the code cannot tell whether the merge failed due to conflicts, it aborts the merge and surfaces the original merge error wrapped as `merge branch %s`.","triggerScenarios":"DOLT_MERGE fails (e.g. unknown branch ref, dirty working set, refspec error) AND the follow-up `SELECT ... FROM dolt_conflicts` query inside GetConflicts also errors, so the conflict-vs-hard-failure distinction cannot be made.","commonSituations":"Merging a ref that does not exist (typo in branch name); working set dirty so DOLT_MERGE refuses; the dolt_conflicts system table missing/unavailable on an old server, compounding the original failure.","solutions":["Check the wrapped inner error: if it says 'unknown branch' or similar, verify the ref exists (`DOLT_BRANCHES` or `bd branch list`)","Commit or stash local changes so the working set is clean before merging","Ensure the Dolt version exposes dolt_conflicts; upgrade if the table query fails","Retry the merge once the underlying cause from the inner error is fixed"],"exampleFix":"// before\nMergeWithStrategy(ctx, db, \"feat/reopsitory-fix\", ...) // typo'd ref\n// after\nMergeWithStrategy(ctx, db, \"feat/repository-fix\", ...)","handlingStrategy":"try-catch","validationCode":"var n int\nif err := db.QueryRowContext(ctx, \"SELECT COUNT(*) FROM dolt_branches WHERE name = ?\", ref).Scan(&n); err != nil || n == 0 {\n    return fmt.Errorf(\"branch %q does not exist\", ref)\n}","typeGuard":null,"tryCatchPattern":"conflicts, err := MergeWithStrategy(ctx, db, ref, strategy, author)\nif err != nil {\n    if strings.Contains(err.Error(), \"unknown\") || strings.Contains(err.Error(), \"not found\") {\n        // bad ref: verify branch name\n    } else if strings.Contains(err.Error(), \"working set\") || strings.Contains(err.Error(), \"dirty\") {\n        // commit/stash first, then retry once\n    }\n}","preventionTips":["Validate the ref exists before merging","Keep the working set clean (commit or stage) before merge calls","Serialize merge operations to avoid concurrent writers"],"tags":["dolt","merge","branch"],"backgroundTag":"dolt-merge-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}