{"record":{"id":"5bfd2a71de8141be","repo":"gastownhall/beads","slug":"scan-schema-conflict-w","errorCode":null,"errorMessage":"scan schema conflict: %w","messagePattern":"scan schema conflict: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/conflicts.go","lineNumber":505,"sourceCode":"\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;\n// anything it declined lands here, blocking the commit.\nfunc constraintViolationCounts(ctx context.Context, db DBConn) ([]storage.ConstraintViolation, error) {\n\trows, err := db.QueryContext(ctx,\n\t\t\"SELECT `table`, num_violations FROM dolt_constraint_violations WHERE num_violations > 0\")\n\tif err != nil {\n\t\tif isMissingSystemTable(err) {\n\t\t\treturn nil, nil","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/conflicts.go#L487-L523","documentation":"While iterating dolt_schema_conflicts rows, a row's table_name value could not be scanned into a Go string — the value was NULL or of an unexpected column type. This usually indicates engine/version drift or a corrupted schema-conflict record, not a normal operating condition.","triggerScenarios":"GetMergeBlockers iterating schema conflict rows where a row's table_name is NULL or of an unexpected type — typically after a dolt engine upgrade/change, a corrupted record, or querying a database whose dolt_schema_conflicts layout differs from what bd expects.","commonSituations":"Mixed dolt versions between what created the merge state and what reads it; manually edited or corrupted dolt metadata; third-party tools writing into dolt system tables.","solutions":["Inspect dolt_schema_conflicts manually (SELECT *) to find the row with a NULL/unusual table_name and fix or clear it.","Resolve the underlying schema conflict properly so the offending row is removed and rewritten.","Check dolt engine version compatibility; upgrade bd or dolt so the expected table layout matches.","If the state is corrupt, abort the merge and redo it after schema alignment."],"exampleFix":"// before: scanning directly into string, NULL fails the scan\nvar t string\nif err := rows.Scan(&t); err != nil { ... }\n// after: tolerant scan for nullability/type drift\nvar t sql.NullString\nif err := rows.Scan(&t); err != nil { ... }\nif !t.Valid { continue } // skip malformed row, report separately","handlingStrategy":"type-guard","validationCode":"// Detect malformed rows before relying on the scan:\nrows, _ := db.QueryContext(ctx, \"SELECT table_name FROM dolt_schema_conflicts\")\nfor rows.Next() {\n  var t sql.NullString\n  if rows.Scan(&t) != nil || !t.Valid { /* corrupt row; inspect via SELECT * */ }\n}","typeGuard":"func validSchemaConflictRow(t sql.NullString) bool { return t.Valid && strings.TrimSpace(t.String) != \"\" }","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"scan schema conflict\") {\n  log.Printf(\"malformed dolt_schema_conflicts row: %v — inspect table manually\", err)\n}","preventionTips":["Keep dolt versions consistent across all writers and readers of the database.","Never hand-edit dolt system tables.","Abort and redo merges whose schema-conflict metadata looks corrupt."],"tags":["dolt","schema-conflicts","scan-error","data-corruption"],"backgroundTag":"sql-scan-type-mismatch","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}