multica-ai/multica · error
scan dry-run summary: %w
Error message
scan dry-run summary: %w
What it means
Returned when rows.Scan fails while reading one dry-run summary row. The query returns nine columns (workspace_id, date_utc, rows, input_before, input_after, overcount, clamped_rows, min/max created), and a scan mismatch — wrong column count/type expectation or a NULL in a non-nullable scan target — produces this. In practice this indicates the binary and the SQL schema are out of sync, not bad user input.
Source
Thrown at server/cmd/backfill_codex_usage_cache/main.go:221
}
defer rows.Close()
var summaries []summaryRow
var total totals
for rows.Next() {
var row summaryRow
if err := rows.Scan(
&row.WorkspaceID,
&row.DateUTC,
&row.Rows,
&row.InputBefore,
&row.InputAfter,
&row.Overcount,
&row.ClampedRows,
&row.MinCreatedUTC,
&row.MaxCreatedUTC,
); err != nil {
return nil, totals{}, fmt.Errorf("scan dry-run summary: %w", err)
}
summaries = append(summaries, row)
total.Rows += row.Rows
total.InputBefore += row.InputBefore
total.InputAfter += row.InputAfter
total.Overcount += row.Overcount
total.ClampedRows += row.ClampedRows
}
if err := rows.Err(); err != nil {
return nil, totals{}, fmt.Errorf("iterate dry-run summary: %w", err)
}
return summaries, total, nil
}
func logSummary(cfg config, rows []summaryRow, total totals) {
slog.Info("Codex usage cache backfill candidate total",
"execute", cfg.execute,
"cutoff", cfg.cutoff.Format(time.RFC3339),View on GitHub (pinned to 2c0912b6ec)
Solutions
- Rebuild/redeploy the backfill binary from the same commit as the database schema (make build within server/).
- Run migrations so schema and binary match, then re-run the dry-run.
- Inspect the wrapped error — pgx names the offending column/type when it is a conversion failure.
Example fix
# before ./old-backfill_codex_usage_cache --cutoff ... # scan dry-run summary: ... (columns moved by migration) # after git checkout <schema-matching-commit> && make -C server build ./server/bin/backfill_codex_usage_cache --cutoff 2026-06-01T12:00:00Z
Defensive patterns
Strategy: validation
Validate before calling
# Ensure binary and schema come from the same commit git -C server log -1 --format=%H > /tmp/backfill.build git checkout $(cat /tmp/backfill.build) && make -C server build
Prevention
- Deploy the backfill binary built from the same release as the schema migrations.
- Never mix an old binary with a migrated database (or vice versa).
- Read the wrapped pgx error — it names the exact column/type that failed to scan.
When it happens
Trigger: Running a backfill binary built against a schema where the summary query returns a different column set than the compiled Scan expects; NULLs appearing in columns scanned into non-pointer types.
Common situations: Schema drifted after the binary was compiled (a migration added/renamed summary columns); using an old binary against an upgraded database or vice versa.
Related errors
- connect to database: %w
- ping database: %w
- acquire advisory-lock connection: %w
- acquire advisory lock %d: %w
- rebuild hourly rollup for update window %s..%s: %w
AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15).
Data as JSON: /api/errors/e1972fe481a1d0ca.
Report an issue: GitHub.