{"record":{"id":"b62ea1970015fcdf","repo":"gastownhall/beads","slug":"failed-to-scan-diff-w","errorCode":null,"errorMessage":"failed to scan diff: %w","messagePattern":"failed to scan diff: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/diff.go","lineNumber":53,"sourceCode":"\n\trows, err := tx.QueryContext(ctx, query)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get diff: %w\", err)\n\t}\n\tdefer rows.Close()\n\n\tvar entries []*storage.DiffEntry\n\tfor rows.Next() {\n\t\tvar fromID, toID, diffType string\n\t\tvar fromTitle, toTitle, fromDesc, toDesc, fromStatus, toStatus *string\n\t\tvar fromPriority, toPriority *int\n\n\t\tif err := rows.Scan(&fromID, &toID, &diffType,\n\t\t\t&fromTitle, &toTitle,\n\t\t\t&fromDesc, &toDesc,\n\t\t\t&fromStatus, &toStatus,\n\t\t\t&fromPriority, &toPriority); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to scan diff: %w\", err)\n\t\t}\n\n\t\tentry := &storage.DiffEntry{\n\t\t\tDiffType: diffType,\n\t\t}\n\n\t\tif toID != \"\" {\n\t\t\tentry.IssueID = toID\n\t\t} else {\n\t\t\tentry.IssueID = fromID\n\t\t}\n\n\t\t// Build old value for modified/removed\n\t\tif diffType != \"added\" && fromID != \"\" {\n\t\t\tentry.OldValue = &types.Issue{\n\t\t\t\tID: fromID,\n\t\t\t}\n\t\t\tif fromTitle != nil {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/diff.go#L35-L71","documentation":"This error wraps a rows.Scan failure while decoding one dolt_diff() result row into the ten expected string columns (from/to id, diff type, title, description, status, priority). Scan fails when a column's value cannot be converted to the target string variable. Note the query already COALESCEs id columns, so failures usually come from unexpected column shapes or engine-level conversion issues.","triggerScenarios":"A dolt_diff result row contains a value the driver cannot decode into a string (NULL in a non-COALESCE'd column with an incompatible driver, unexpected column type from a Dolt version change, or a column-count mismatch after a schema/engine update).","commonSituations":"Dolt server version differences changing dolt_diff column types; schema changes on issues (e.g. priority becoming an int) that the driver refuses to scan into string; corrupted rows.","solutions":["Check the wrapped cause to see which column failed to convert","Verify the Dolt server version matches what the library expects; upgrade/downgrade if dolt_diff's output shape changed","Check the issues table schema at the diffed refs for changed column types","If a column type changed (e.g. priority now numeric), cast it to CHAR in the query before scanning"],"exampleFix":"// before\n&fromPriority, &toPriority); err != nil {\n    return nil, fmt.Errorf(\"failed to scan diff: %w\", err)\n}\n// after\n// in the query: CAST(from_priority AS CHAR) as from_priority, CAST(to_priority AS CHAR) as to_priority\n&fromPriority, &toPriority); err != nil {\n    return nil, fmt.Errorf(\"failed to scan diff (column type mismatch?): %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// verify dolt_diff column shape matches expectations before scanning\ncols, err := queryColumns(ctx, tx, fmt.Sprintf(\"SELECT * FROM dolt_diff('%s','%s','issues') LIMIT 1\", from, to))\nif err != nil {\n    return err\n}\nif len(cols) != 10 {\n    return fmt.Errorf(\"dolt_diff returned %d columns; library expects 10 — check Dolt version\", len(cols))\n}","typeGuard":null,"tryCatchPattern":"entries, err := issueops.DiffInTx(ctx, tx, from, to)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to scan diff\") {\n        log.Errorf(\"diff row decode failed; verify Dolt version and issues-table column types: %v\", err)\n    }\n    return err\n}","preventionTips":["Pin a compatible Dolt server version and test upgrades against diff queries","CAST non-string columns (e.g. priority) to CHAR if the schema made them numeric","Verify the issues schema at both refs hasn't changed column order/types","Report the wrapped scan error verbatim in bug reports — it names the failing column"],"tags":["database","dolt","sql","scan"],"backgroundTag":"sql-scan-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}