{"record":{"id":"dfaa139d91abe297","repo":"gastownhall/beads","slug":"query-conflicts-for-table-s-w-dfaa13","errorCode":null,"errorMessage":"query conflicts for table %s: %w","messagePattern":"query conflicts for table (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/conflicts.go","lineNumber":122,"sourceCode":"\tcase time.Time:\n\t\ts = t.UTC().Format(time.RFC3339)\n\tdefault:\n\t\ts = fmt.Sprint(t)\n\t}\n\treturn &s\n}\n\n// GetConflictRows returns the live conflicted rows of table, one entry per\n// conflicted row with its columns presented per field. It reads the working\n// set: a merge whose conflicts were aborted (the auto-settle path) leaves\n// nothing here, which is correct — those conflicts no longer exist.\nfunc GetConflictRows(ctx context.Context, db DBConn, table string) ([]storage.ConflictRow, error) {\n\tif err := ValidateConflictTable(table); err != nil {\n\t\treturn nil, err\n\t}\n\trows, err := db.QueryContext(ctx, \"SELECT * FROM `dolt_conflicts_\"+table+\"`\") //nolint:gosec // table validated as an identifier above\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"query conflicts for table %s: %w\", table, err)\n\t}\n\tdefer func() { _ = rows.Close() }()\n\n\tcols, err := rows.Columns()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"conflict columns for table %s: %w\", table, err)\n\t}\n\n\tvar out []storage.ConflictRow\n\tfor rows.Next() {\n\t\tvals := make([]any, len(cols))\n\t\tptrs := make([]any, len(cols))\n\t\tfor i := range vals {\n\t\t\tptrs[i] = &vals[i]\n\t\t}\n\t\tif err := rows.Scan(ptrs...); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"scan conflict row for table %s: %w\", table, err)\n\t\t}","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/conflicts.go#L104-L140","documentation":"GetConflictRows failed while executing the SELECT against the dolt_conflicts_<table> system table. This wraps the underlying driver error, meaning the query itself could not be executed — the table name was already validated as an identifier, so the failure comes from dolt or the connection. The wrapped cause (%w) carries the real reason.","triggerScenarios":"Calling GetConflictRows(ctx, db, table) when the underlying dolt_conflicts_<table> system table does not exist (no conflict for that table), when the connection is broken/closed, or when the session lacks permission to query the conflicts table.","commonSituations":"Querying conflicts after the merge was fully resolved (conflict rows already cleared); querying a table that never had a merge conflict; connection dropped mid-session or pool checkout failure; running against an older dolt version that names conflicts tables differently.","solutions":["Check the wrapped driver error (%w) for the root cause — missing table vs connection failure","Confirm a merge with conflicts actually happened (e.g. via dolt_conflicts or merge status) before calling GetConflictRows","Verify the connection is alive and the session is still open","Check dolt version supports the dolt_conflicts_<table> system table"],"exampleFix":"// before\nrows, err := versioncontrolops.GetConflictRows(ctx, db, \"issues\") // assumes conflicts exist\n// after\nif ok, _ := versioncontrolops.HasConflicts(ctx, db, \"issues\"); ok {\n    rows, err := versioncontrolops.GetConflictRows(ctx, db, \"issues\")\n}","handlingStrategy":"try-catch","validationCode":"var n int\nif err := db.QueryRowContext(ctx, \"SELECT COUNT(*) FROM `dolt_conflicts_` + table\").Scan(&n); err != nil || n == 0 {\n    return nil, nil // no conflicts to read\n}","typeGuard":null,"tryCatchPattern":"rows, err := versioncontrolops.GetConflictRows(ctx, db, table)\nif err != nil {\n    if strings.Contains(err.Error(), \"doesn't exist\") {\n        return nil, nil // treat as no conflicts\n    }\n    return fmt.Errorf(\"get conflict rows: %w\", err)\n}","preventionTips":["Confirm a conflicted merge exists before querying conflicts","Keep the dolt session alive for the whole conflict-handling flow","Pin matching dolt server and driver versions"],"tags":["database","dolt","conflict-resolution","sql"],"backgroundTag":"sql-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}