unslothai/unsloth · error · HTTPException
empty upload payload
Error message
empty upload payload
What it means
Raised after _decode_base64_payload returns falsy, meaning the content_base64 field decoded to zero bytes (or decoding yielded an empty result). The endpoint refuses to store an empty file, returning HTTP 400 with 'empty upload payload'. This is a client-side data problem, not a server fault.
Source
Thrown at studio/backend/routes/data_recipe/seed.py:671
_LEGACY_UNSTRUCTURED_EXTS = {".txt", ".md"}
if seed_source_type == "unstructured":
if ext not in _LEGACY_UNSTRUCTURED_EXTS:
allowed = ", ".join(sorted(_LEGACY_UNSTRUCTURED_EXTS))
raise HTTPException(
status_code = 400,
detail = f"unsupported file type: {ext}. allowed: {allowed}",
)
else:
if ext not in LOCAL_UPLOAD_EXTS:
allowed = ", ".join(sorted(LOCAL_UPLOAD_EXTS))
raise HTTPException(
status_code = 400,
detail = f"unsupported file type: {ext}. allowed: {allowed}",
)
file_bytes = _decode_base64_payload(payload.content_base64)
if not file_bytes:
raise HTTPException(status_code = 400, detail = "empty upload payload")
if len(file_bytes) > LOCAL_SEED_UPLOAD_MAX_BYTES:
raise HTTPException(
status_code = 413,
detail = f"file too large (max {LOCAL_SEED_UPLOAD_MAX_LABEL})",
)
ensure_dir(SEED_UPLOAD_DIR)
stored_name = f"{uuid4().hex}_{filename}"
stored_path = SEED_UPLOAD_DIR / stored_name
stored_path.write_bytes(file_bytes)
if seed_source_type == "unstructured":
preview_rows = _read_preview_rows_from_unstructured_file(
path = stored_path,
preview_size = int(payload.preview_size),
chunk_size = payload.unstructured_chunk_size,
chunk_overlap = payload.unstructured_chunk_overlap,
)View on GitHub (pinned to 203007d190)
Solutions
- Verify the source file exists and has non-zero size before encoding it.
- Log the length of the base64 string client-side; anything under a few characters is a bug in the upload pipeline.
- Check that the field name sent by the client matches the schema's content_base64 exactly (no truncation by a proxy or body parser).
Example fix
// before
const b64 = btoa(file.name); // encodes the NAME, not contents
// after
const b64 = await fileToBase64(file); // reads File contents
if (!b64 || b64.length < 4) throw new Error('file is empty'); Defensive patterns
Strategy: validation
Validate before calling
const bytes = await file.arrayBuffer();
if (bytes.byteLength === 0) throw new Error('selected file is empty');
const b64 = base64FromBytes(bytes); Prevention
- Check file.size > 0 in the picker before reading.
- Unit-test the base64 conversion helper against empty inputs.
When it happens
Trigger: POST with content_base64 set to an empty string, base64 of b'' (i.e. '' or '=' padding artifacts), a base64 string that decodes to nothing, or the field omitted while the schema defaults it to empty. Occurs after the extension checks pass.
Common situations: Reading the file before it is fully written (0-byte read); base64-encoding an empty buffer because the file picker returned an empty File; a multipart-to-base64 conversion bug that drops the payload.
Related errors
- Invalid base64 image data: {exc}
- A reference decoded to no data.
- each reference image must be at most 32 MiB (base64)
- each reference must be at most 32 MiB (base64)
- nonce must be base64url
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/b5e4b24639b95802.
Report an issue: GitHub.