{"record":{"id":"d5c9e82ab8b24d9a","repo":"we-promise/sure","slug":"max-row-count-exceeded","errorCode":"max_row_count_exceeded","errorMessage":"Import was uploaded but has too many rows to publish automatically.","messagePattern":"Import was uploaded but has too many rows to publish automatically\\.","errorType":"http","errorClass":"Import::MaxRowCountExceededError","httpStatus":422,"severity":"warning","filePath":"app/models/import.rb","lineNumber":236,"sourceCode":"\n          parsed_count += 1\n          reasonable_count += 1 if reasonable_range.cover?(date)\n        end\n\n        { format: fmt, parsed: parsed_count, reasonable: reasonable_count }\n      end\n\n      # Filter to candidates that parsed at least one sample\n      viable = scored.select { |s| s[:parsed] > 0 }\n      return fallback if viable.empty?\n\n      best = viable.max_by { |s| [ s[:parsed], s[:reasonable] ] }\n      best[:format]\n    end\n  end\n\n  def publish_later\n    raise MaxRowCountExceededError if row_count_exceeded?\n    raise \"Import is not publishable\" unless publishable?\n\n    update! status: :importing\n\n    ImportJob.perform_later(self)\n  end\n\n  # Whether import! already committed rows for this import. Distinguishes a\n  # job that died mid-import (single transaction → rolled back, nothing\n  # attached) from one that died after the data landed but before the status\n  # write. Covers entry-producing imports and account-producing ones\n  # (AccountImport creates accounts, not entries).\n  def data_committed?\n    entries.exists? || accounts.exists?\n  end\n\n  # Reaper guard: still wedged in a job-owned status and untouched since the\n  # sweep's cutoff. Called under the record's row lock (fresh read).","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/import.rb#L218-L254","documentation":"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.","triggerScenarios":"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).","commonSituations":"Multi-year bank statement exports; users concatenating statements into one file; import types whose subclass limit differs from the base 10,000.","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"],"exampleFix":"// before\nimport.publish_later # raises Import::MaxRowCountExceededError\n\n// after\nif import.rows_count > import.max_row_count\n  # surface a split-the-file message to the user\nelse\n  import.publish_later\nend","handlingStrategy":"validation","validationCode":"import.rows_count <= import.max_row_count # false => publish_later raises MaxRowCountExceededError; Preflight also warns at lint time","typeGuard":null,"tryCatchPattern":"rescue Import::MaxRowCountExceededError in publish endpoints and return an unprocessable-entity response instructing the user to split the file","preventionTips":["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"],"tags":["import","csv","row-limit","upload"],"backgroundTag":"row-limit-exceeded","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}