{"record":{"id":"6efe7b912bb87e4a","repo":"gastownhall/beads","slug":"query-schema-conflicts-w","errorCode":null,"errorMessage":"query schema conflicts: %w","messagePattern":"query schema conflicts: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/conflicts.go","lineNumber":498,"sourceCode":"\terr := db.QueryRowContext(ctx, \"SELECT is_merging FROM dolt_merge_status\").Scan(&merging)\n\tif err != nil {\n\t\tif isMissingSystemTable(err) || errors.Is(err, sql.ErrNoRows) {\n\t\t\treturn false, nil\n\t\t}\n\t\treturn false, fmt.Errorf(\"query merge status: %w\", err)\n\t}\n\treturn merging, nil\n}\n\n// schemaConflictTables lists the tables whose SCHEMAS conflict — dolt keeps\n// them out of dolt_conflicts entirely, so totalConflicts cannot see them.\nfunc schemaConflictTables(ctx context.Context, db DBConn) ([]string, error) {\n\trows, err := db.QueryContext(ctx, \"SELECT table_name FROM dolt_schema_conflicts\")\n\tif err != nil {\n\t\tif isMissingSystemTable(err) {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"query schema conflicts: %w\", err)\n\t}\n\tdefer func() { _ = rows.Close() }()\n\tvar tables []string\n\tfor rows.Next() {\n\t\tvar t string\n\t\tif err := rows.Scan(&t); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"scan schema conflict: %w\", err)\n\t\t}\n\t\ttables = append(tables, t)\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"iterate schema conflicts: %w\", err)\n\t}\n\treturn tables, nil\n}\n\n// constraintViolationCounts lists the tables carrying outstanding constraint\n// violations. mergesettle.go repairs the FK-cascade class on the auto path;","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/conflicts.go#L480-L516","documentation":"schemaConflictTables lists tables with schema-level conflicts from dolt_schema_conflicts; this error wraps any query failure that is NOT the table being missing (absence is intentionally treated as 'no schema conflicts'). It means the merge-blocker diagnostic could not read schema conflict state.","triggerScenarios":"GetMergeBlockers querying dolt_schema_conflicts and receiving a non-missing-table SQL error: connection failure, permission denial, engine error while a merge is open, or a dolt version where the table exists with a different layout (e.g. no table_name column).","commonSituations":"Older dolt versions reporting a different error than 'table not found'; revoked privileges on dolt_* system tables in server mode; transient server disconnects during a long merge session.","solutions":["Read the wrapped cause: fix connectivity or grant SELECT on dolt_schema_conflicts to the connecting user.","If the error indicates an unknown column, align the dolt engine version with bd's expectations.","Retry the diagnosis after the merge state stabilizes; mid-merge engine errors are often transient.","As a fallback, inspect schema conflicts directly in the repo with dolt's own conflicts commands."],"exampleFix":"// before: hard-failing the command on a diagnosis query\nblockers, err := ops.GetMergeBlockers(ctx, db)\nif err != nil { return err }\n// after: log partial errors and use readable blockers\nblockers, err := ops.GetMergeBlockers(ctx, db)\nif err != nil { log.Printf(\"partial diagnosis: %v\", err) }\nuse(blockers.SchemaConflictTables)","handlingStrategy":"try-catch","validationCode":"// Verify access to the schema conflicts table first:\nrows, err := db.QueryContext(ctx, \"SELECT table_name FROM dolt_schema_conflicts\")\nif err != nil && !missingTable(err) {\n  // diagnose connectivity/permissions before the full check\n}","typeGuard":null,"tryCatchPattern":"blockers, err := ops.GetMergeBlockers(ctx, db)\nif err != nil {\n  if strings.Contains(err.Error(), \"query schema conflicts\") {\n    log.Printf(\"schema conflicts unreadable: %v\", err) // use partial results\n  } else { return err }\n}","preventionTips":["Grant SELECT on dolt_* system tables to the bd database user.","Keep the dolt engine version aligned with bd's expectations.","Retry diagnosis after transient server errors instead of failing the command."],"tags":["dolt","schema-conflicts","system-table","diagnostics"],"backgroundTag":"dolt-system-table-unavailable","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}