we-promise/sure · warning · Import::MaxRowCountExceededError
max_row_count_exceeded
max_row_count_exceeded
Error message
Import was uploaded but has too many rows to publish automatically.
What it means
Import#publish_later refuses to enqueue when rows_count exceeds max_row_count (10,000 in the base Import class at app/models/import.rb:529; AccountImport overrides; ImportSession checks the sum against SureImport.max_row_count). MaxRowCountExceededError means the file parsed and uploaded fine but is too large to auto-publish — the limit bounds job memory.
Source
Thrown at app/models/import.rb:236
parsed_count += 1
reasonable_count += 1 if reasonable_range.cover?(date)
end
{ format: fmt, parsed: parsed_count, reasonable: reasonable_count }
end
# Filter to candidates that parsed at least one sample
viable = scored.select { |s| s[:parsed] > 0 }
return fallback if viable.empty?
best = viable.max_by { |s| [ s[:parsed], s[:reasonable] ] }
best[:format]
end
end
def publish_later
raise MaxRowCountExceededError if row_count_exceeded?
raise "Import is not publishable" unless publishable?
update! status: :importing
ImportJob.perform_later(self)
end
# Whether import! already committed rows for this import. Distinguishes a
# job that died mid-import (single transaction → rolled back, nothing
# attached) from one that died after the data landed but before the status
# write. Covers entry-producing imports and account-producing ones
# (AccountImport creates accounts, not entries).
def data_committed?
entries.exists? || accounts.exists?
end
# Reaper guard: still wedged in a job-owned status and untouched since the
# sweep's cutoff. Called under the record's row lock (fresh read).View on GitHub (pinned to e69894adb9)
Solutions
- Split the file into chunks under the limit and publish each as its own import
- Pre-check import.rows_count > import.max_row_count before publish_later and tell the user to split, rather than letting the exception fire
- If the limit is genuinely wrong for your install, deliberately raise Import#max_row_count (or SureImport.max_row_count) — do not silently bypass it
Example fix
// before import.publish_later # raises Import::MaxRowCountExceededError // after if import.rows_count > import.max_row_count # surface a split-the-file message to the user else import.publish_later end
Defensive patterns
Strategy: validation
Validate before calling
import.rows_count <= import.max_row_count # false => publish_later raises MaxRowCountExceededError; Preflight also warns at lint time
Try / catch
rescue Import::MaxRowCountExceededError in publish endpoints and return an unprocessable-entity response instructing the user to split the file
Prevention
- Warn at preflight (Import::Preflight already flags the row-count warning) so users learn before publish
- Split large exports client-side or server-side into multiple imports
- Know the limit per import type — base Import is 10,000; AccountImport overrides; sessions sum against SureImport.max_row_count
When it happens
Trigger: Uploading a CSV/QIF whose parsed rows_count exceeds max_row_count and then calling publish_later. Import::Preflight already emits the warning 'Row count exceeds this import type's publish limit.' at lint time (app/models/import/preflight.rb:149).
Common situations: Multi-year bank statement exports; users concatenating statements into one file; import types whose subclass limit differs from the base 10,000.
Related errors
AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21).
Data as JSON: /api/errors/d5c9e82ab8b24d9a.
Report an issue: GitHub.