{"record":{"id":"371055b20b606411","repo":"unslothai/unsloth","slug":"file-too-large-size-bytes-bytes-maximum-is-u","errorCode":null,"errorMessage":"File too large ({size_bytes} bytes). Maximum is {UNSTRUCTURED_RECIPE_UPLOAD_MAX_LABEL}.","messagePattern":"File too large \\((.+?) bytes\\)\\. Maximum is (.+?)\\.","errorType":"http","errorClass":"HTTPException","httpStatus":413,"severity":"error","filePath":"studio/backend/routes/data_recipe/seed.py","lineNumber":457,"sourceCode":") -> UnstructuredFileUploadResponse:\n    _validate_safe_id(block_id, \"block_id\")\n\n    original_filename = file.filename or \"upload\"\n    ext = Path(original_filename).suffix.lower()\n    if ext not in UNSTRUCTURED_ALLOWED_EXTS:\n        raise HTTPException(\n            400,\n            f\"Unsupported file type: {ext}. Allowed: {', '.join(sorted(UNSTRUCTURED_ALLOWED_EXTS))}\",\n        )\n\n    content = await file.read()\n    size_bytes = len(content)\n\n    if size_bytes == 0:\n        raise HTTPException(400, \"Empty file not allowed\")\n\n    if size_bytes > UNSTRUCTURED_RECIPE_UPLOAD_MAX_BYTES:\n        raise HTTPException(\n            413,\n            f\"File too large ({size_bytes} bytes). Maximum is {UNSTRUCTURED_RECIPE_UPLOAD_MAX_LABEL}.\",\n        )\n\n    block_dir = UNSTRUCTURED_UPLOAD_ROOT / block_id\n    ensure_dir(block_dir)\n    current_total = _get_block_total_size(block_dir)\n    if current_total + size_bytes > UNSTRUCTURED_RECIPE_UPLOAD_TOTAL_MAX_BYTES:\n        raise HTTPException(\n            413,\n            f\"Total upload limit ({UNSTRUCTURED_RECIPE_UPLOAD_TOTAL_MAX_LABEL}) exceeded\",\n        )\n\n    file_id = uuid4().hex\n    raw_path = block_dir / f\"{file_id}{ext}\"\n    raw_path.write_bytes(content)\n\n    extracted_path = block_dir / f\"{file_id}.extracted.txt\"","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/data_recipe/seed.py#L439-L475","documentation":"HTTP 413 raised by POST /seed/upload-unstructured-file when a single file exceeds UNSTRUCTURED_RECIPE_UPLOAD_MAX_BYTES. The whole body is read into memory first, then the per-file cap is enforced; the message reports the actual size and the human-readable max (UNSTRUCTURED_RECIPE_UPLOAD_MAX_LABEL).","triggerScenarios":"Uploading one large PDF/docx above the configured per-file limit (message states size and max explicitly).","commonSituations":"Scanned-book PDFs or large exports; environment variable tuning the limit down after big files were already in use; users unaware of the cap.","solutions":["Split the document (extract chapters/ranges) and upload parts under the limit.","Reduce PDF size (compress images, e.g. gs or qpdf) before upload.","If policy allows, raise UNSTRUCTURED_RECIPE_UPLOAD_MAX_BYTES in backend config."],"exampleFix":"# before\nupload(myfile.pdf)  # 250MB, limit 100MB\n\n# after\nqpdf --split-pages myfile.pdf --out-file part  # then upload part-01.pdf etc.","handlingStrategy":"validation","validationCode":"const MAX = UNSTRUCTURED_MAX_BYTES; // keep in sync with backend config\nif (file.size > MAX) throw new Error(`split ${file.name} (${file.size} > ${MAX})`);","typeGuard":"function isUnderPerFileLimit(f: File, max: number): boolean { return f.size <= max; }","tryCatchPattern":"On 413 with the per-file message, prompt the user to split/compress that specific file; upload the remaining files that passed validation.","preventionTips":["Show the per-file limit in the upload UI and validate client-side.","Compress PDFs and split large documents as part of the ingestion flow."],"tags":["upload","size-limit","http-413","unstructured"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}