{"record":{"id":"34e3ea22c48370b0","repo":"gastownhall/beads","slug":"pull-merge-left-constraint-violations-bd-cannot-au","errorCode":null,"errorMessage":"pull merge left constraint violations bd cannot auto-repair; inspect dolt_constraint_violations and resolve before retrying","messagePattern":"pull merge left constraint violations bd cannot auto-repair; inspect dolt_constraint_violations and resolve before retrying","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/store.go","lineNumber":4474,"sourceCode":"\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 be committed.\n\trepairedViol, hadViol, violErr := s.tryRepairFKCascadeViolations(ctx, tx)\n\tif violErr != nil {\n\t\t_ = tx.Rollback()\n\t\tif pullErr != nil {\n\t\t\treturn pullErr\n\t\t}\n\t\treturn violErr\n\t}\n\tif hadViol && !repairedViol {\n\t\t_ = tx.Rollback()\n\t\tif pullErr != nil {\n\t\t\treturn pullErr\n\t\t}\n\t\treturn fmt.Errorf(\"pull merge left constraint violations bd cannot auto-repair; inspect dolt_constraint_violations and resolve before retrying\")\n\t}\n\n\tif pullErr != nil && !resolved && !repairedViol {\n\t\t// Pull failed for a non-conflict reason, or conflicts include non-metadata tables.\n\t\t_ = tx.Rollback()\n\t\treturn pullErr\n\t}\n\n\t// Conclude the merge for resolved conflicts only now, after the FK repair:\n\t// DOLT_COMMIT refuses a violated working set, so a merge carrying both\n\t// classes could never settle when the resolver committed first (bd-578h9.14).\n\tif resolved {\n\t\tif err := versioncontrolops.CommitResolvedConflicts(ctx, tx); err != nil {\n\t\t\t_ = tx.Rollback()\n\t\t\tif pullErr != nil {\n\t\t\t\treturn pullErr\n\t\t\t}\n\t\t\treturn err","sourceCodeStart":4456,"sourceCodeEnd":4492,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/store.go#L4456-L4492","documentation":"Raised when a pull merge produced rows in dolt_constraint_violations and bd's automatic repair (tryRepairFKCascadeViolations) could not fully clear them. bd refuses to commit any state that still contains constraint violations, rolls the transaction back, and returns this error so the user resolves the violations manually before retrying.","triggerScenarios":"A `bd dolt pull` merges remote commits whose foreign-key/dependency rows conflict with local rows in a way the built-in cascade repair does not cover — e.g. both sides edited the same dependency edge with incompatible cascade semantics.","commonSituations":"Two clones concurrently edited the same issue's dependencies (a dependency deleted locally but modified remotely); merge of divergent blocked-status data; schema-version skew between clones producing rows the repair rules don't recognize.","solutions":["Query dolt_constraint_violations to see the offending rows: `SELECT * FROM dolt_constraint_violations;`","Resolve each violation manually (delete or correct the conflicting dependency/issue rows)","Clear resolved entries from dolt_constraint_violations","Re-run `bd dolt pull` to complete the merge","If violations recur from a specific clone, reconcile that clone's data before pulling"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before retrying the pull, confirm violations are cleared\nrows, err := db.Query(\"SELECT COUNT(*) FROM dolt_constraint_violations\")\n// count must be 0 before retrying","typeGuard":null,"tryCatchPattern":"if err := store.Pull(ctx); err != nil {\n    if strings.Contains(err.Error(), \"constraint violations bd cannot auto-repair\") {\n        // inspect and resolve manually, then retry\n        // SELECT * FROM dolt_constraint_violations;\n        return fmt.Errorf(\"manual resolution required: %w\", err)\n    }\n    return err\n}","preventionTips":["Avoid editing the same dependency edges on two clones concurrently","Pull frequently to keep divergence small","Reconcile divergent clones before large merges","Keep schema versions identical across clones"],"tags":["dolt","constraint-violation","merge","foreign-key"],"backgroundTag":"dolt-constraint-violation-unresolved","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}