{"record":{"id":"beba43ea52f1245f","repo":"gastownhall/beads","slug":"failed-to-query-conflicts-w","errorCode":null,"errorMessage":"failed to query conflicts: %w","messagePattern":"failed to query conflicts: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/mergesettle.go","lineNumber":432,"sourceCode":"//\n//   - comments/events: append-only union. Rows are insert-only and keyed by a\n//     per-machine-unique id, so creation is disjoint; a same-id conflict whose\n//     columns agree is the same append on both sides and is resolved by\n//     keeping it. A row missing on one side, or diverging columns in a\n//     supposedly immutable row, is left for the operator.\n//\n// Any conflict on another table, or an unresolvable dependencies,\n// schema_migrations, config, issues, labels, comments, or events conflict,\n// returns (false, nil) so the caller fails the pull and the operator resolves\n// it.\n//\n// The resolved tables are staged but NOT committed: the caller must run\n// CommitResolvedConflicts after the FK cascade repair, because DOLT_COMMIT\n// refuses a working set with outstanding constraint violations (bd-578h9.14).\nfunc TryAutoResolveMergeConflicts(ctx context.Context, db DBConn) (bool, error) {\n\trows, err := db.QueryContext(ctx, \"SELECT `table`, num_conflicts FROM dolt_conflicts\")\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to query conflicts: %w\", err)\n\t}\n\n\ttype conflict struct {\n\t\ttable string\n\t\tcount int\n\t}\n\tvar conflicts []conflict\n\tfor rows.Next() {\n\t\tvar c conflict\n\t\tif err := rows.Scan(&c.table, &c.count); err != nil {\n\t\t\t_ = rows.Close()\n\t\t\treturn false, fmt.Errorf(\"failed to scan conflict: %w\", err)\n\t\t}\n\t\tconflicts = append(conflicts, c)\n\t}\n\t_ = rows.Close()\n\tif err := rows.Err(); err != nil {\n\t\treturn false, err","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/mergesettle.go#L414-L450","documentation":"TryAutoResolveMergeConflicts starts by reading `SELECT \\`table\\`, num_conflicts FROM dolt_conflicts`. If that query itself fails, the auto-resolve pass cannot enumerate conflicts and returns this wrapped error, aborting automatic settlement.","triggerScenarios":"The dolt_conflicts table is missing (Dolt version too old, or no merge in progress in some server modes), the connection errored, or the query was rejected by permissions/context cancellation.","commonSituations":"Calling SettleMerge when no merge is active on a server that errors rather than returning empty rows; context deadline exceeded mid-query; old embedded Dolt lacking the dolt_conflicts table.","solutions":["Verify Dolt version supports dolt_conflicts; upgrade if missing","Run the SELECT manually to see the raw error","Check context timeout/cancellation and retry with a longer deadline","If no merge is in progress, confirm merge state before calling SettleMerge"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if _, err := db.QueryContext(ctx, \"SELECT 1 FROM dolt_conflicts LIMIT 1\"); err != nil {\n    return errors.New(\"dolt_conflicts unavailable; check Dolt version/merge state\")\n}","typeGuard":null,"tryCatchPattern":"ok, err := TryAutoResolveMergeConflicts(ctx, db)\nif err != nil {\n    if ctx.Err() != nil { // deadline/cancel — retry with larger timeout\n        ctx2, cancel := context.WithTimeout(context.Background(), 60*time.Second)\n        defer cancel()\n        ok, err = TryAutoResolveMergeConflicts(ctx2, db)\n    }\n}","preventionTips":["Set ample context timeouts for settle operations","Confirm an active merge before calling SettleMerge","Keep Dolt engine version current"],"tags":["dolt","conflicts","query"],"backgroundTag":"dolt-conflict-table-unavailable","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}