unslothai/unsloth · error · HTTPException
File too large ({size_bytes} bytes). Maximum is {UNSTRUCTURE
Error message
File too large ({size_bytes} bytes). Maximum is {UNSTRUCTURED_RECIPE_UPLOAD_MAX_LABEL}. What it means
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).
Source
Thrown at studio/backend/routes/data_recipe/seed.py:457
) -> UnstructuredFileUploadResponse:
_validate_safe_id(block_id, "block_id")
original_filename = file.filename or "upload"
ext = Path(original_filename).suffix.lower()
if ext not in UNSTRUCTURED_ALLOWED_EXTS:
raise HTTPException(
400,
f"Unsupported file type: {ext}. Allowed: {', '.join(sorted(UNSTRUCTURED_ALLOWED_EXTS))}",
)
content = await file.read()
size_bytes = len(content)
if size_bytes == 0:
raise HTTPException(400, "Empty file not allowed")
if size_bytes > UNSTRUCTURED_RECIPE_UPLOAD_MAX_BYTES:
raise HTTPException(
413,
f"File too large ({size_bytes} bytes). Maximum is {UNSTRUCTURED_RECIPE_UPLOAD_MAX_LABEL}.",
)
block_dir = UNSTRUCTURED_UPLOAD_ROOT / block_id
ensure_dir(block_dir)
current_total = _get_block_total_size(block_dir)
if current_total + size_bytes > UNSTRUCTURED_RECIPE_UPLOAD_TOTAL_MAX_BYTES:
raise HTTPException(
413,
f"Total upload limit ({UNSTRUCTURED_RECIPE_UPLOAD_TOTAL_MAX_LABEL}) exceeded",
)
file_id = uuid4().hex
raw_path = block_dir / f"{file_id}{ext}"
raw_path.write_bytes(content)
extracted_path = block_dir / f"{file_id}.extracted.txt"View on GitHub (pinned to 203007d190)
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.
Example fix
# before upload(myfile.pdf) # 250MB, limit 100MB # after qpdf --split-pages myfile.pdf --out-file part # then upload part-01.pdf etc.
Defensive patterns
Strategy: validation
Validate before calling
const MAX = UNSTRUCTURED_MAX_BYTES; // keep in sync with backend config
if (file.size > MAX) throw new Error(`split ${file.name} (${file.size} > ${MAX})`); Type guard
function isUnderPerFileLimit(f: File, max: number): boolean { return f.size <= max; } Try / catch
On 413 with the per-file message, prompt the user to split/compress that specific file; upload the remaining files that passed validation.
Prevention
- 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.
When it happens
Trigger: Uploading one large PDF/docx above the configured per-file limit (message states size and max explicitly).
Common situations: Scanned-book PDFs or large exports; environment variable tuning the limit down after big files were already in use; users unaware of the cap.
Related errors
- Total upload limit ({UNSTRUCTURED_RECIPE_UPLOAD_TOTAL_MAX_LA
- Dataset upload too large. Maximum is {get_upload_limit_label
- Unsupported file type: {ext}. Allowed: {', '.join(sorted(UNS
- File exceeds the {cap // (1024 * 1024)} MB upload limit.
- Image is too large ({w}x{h}); maximum is {max_side}px per si
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/371055b20b606411.
Report an issue: GitHub.