{"record":{"id":"67e5e0802a5c2f84","repo":"we-promise/sure","slug":"file-too-large","errorCode":"file_too_large","errorMessage":"File is too large. Maximum size is #{Import.max_csv_size / 1.megabyte}MB.","messagePattern":"File is too large\\. Maximum size is #(.+?)MB\\.","errorType":"http","errorClass":"Import::Preflight::PreflightError","httpStatus":422,"severity":"error","filePath":"app/models/import/preflight.rb","lineNumber":395,"sourceCode":"        payload: {\n          error: \"content_too_large\",\n          message: \"Content is too large. Maximum size is #{SureImport.max_ndjson_size / 1.megabyte}MB.\"\n        }\n      )\n    end\n\n    def invalid_sure_file_type_response\n      Response.new(\n        status: :unprocessable_entity,\n        payload: {\n          error: \"invalid_file_type\",\n          message: \"Invalid file type. Please upload a Sure NDJSON file.\"\n        }\n      )\n    end\n\n    def raise_response(response)\n      raise PreflightError, response\n    end\n\n    def unsupported_import_type_response\n      Response.new(\n        status: :unprocessable_entity,\n        payload: {\n          error: \"unsupported_import_type\",\n          message: \"Preflight supports CSV import types and SureImport.\"\n        }\n      )\n    end\nend\n","sourceCodeStart":377,"sourceCodeEnd":408,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/import/preflight.rb#L377-L408","documentation":"Import::Preflight#csv_file_upload_attributes (app/models/import/preflight.rb:189) rejects a multipart CSV upload with HTTP 422 {error: 'file_too_large'} when file.size exceeds Import.max_csv_size, the hard-coded constant Import::MAX_CSV_SIZE = 10.megabytes (app/models/import.rb:35) — there is no ENV override for the CSV cap. Because preflight reads and parses the whole file, size is checked before any parsing runs. The same 10MB guard is enforced again at import creation (app/controllers/api/v1/imports_controller.rb:80).","triggerScenarios":"POST to the import preflight or import create endpoints with params[:file] larger than 10MB, e.g. a 14MB multi-year bank transaction CSV upload.","commonSituations":"Full-history CSV exports from banks or brokerages; exports with many unused columns; assuming gzip request compression raises the limit — the server measures the decoded uploaded file, not the transfer size.","solutions":["Split the CSV into files under 10MB and run one import per part","Re-export a narrower date range or drop unneeded columns from the source","Convert the data to SureImport NDJSON, whose size cap is env-tunable on self-hosted installs (SURE_IMPORT_MAX_NDJSON_SIZE_MB)","Self-hosted only: edit Import::MAX_CSV_SIZE in app/models/import.rb and redeploy — no ENV knob exists for the CSV cap"],"exampleFix":"# before: single 14MB upload → 422 file_too_large\nsplit -b 9m export.csv part_\n# after: upload each part under 10MB\nfor f in part_*; do curl -F \"file=@${f};type=text/csv\" -H 'X-Api-Key: k' https://app/api/v1/imports; done","handlingStrategy":"validation","validationCode":"MAX_CSV_BYTES = 10 * 1024 * 1024 # Import::MAX_CSV_SIZE\nsize = File.size(path)\nraise \"CSV is #{size} bytes, max #{MAX_CSV_BYTES} — split it\" if size > MAX_CSV_BYTES","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check File.size before every CSV upload; split exports at ~9MB boundaries on line ends","Re-export narrower date ranges instead of shipping full history in one file","Remember the cap applies to the decoded upload — request compression does not help"],"tags":["rails","import","csv","file-upload","size-limit","http-422"],"backgroundTag":"payload-too-large","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}