unslothai/unsloth · error · HTTPException

No dataset file was provided

Error message

No dataset file was provided

What it means

HTTP 400 from the multipart upload path when no `file` part was provided and no native_path_lease was supplied either — the request reached the handler with nothing to upload. It is a request-shape error, occurring before destination validation or any disk writes.

Source

Thrown at studio/backend/hub/services/datasets/local.py:364

                stored_path.unlink(missing_ok = True)

    if written == 0:
        stored_path.unlink(missing_ok = True)
        raise HTTPException(status_code = 400, detail = "Dropped dataset is empty")

    return UploadDatasetResponse(filename = filename, stored_path = str(stored_path))


async def upload_dataset_response(
    file: UploadFile | None, native_path_lease: str | None = None
) -> UploadDatasetResponse:
    if native_path_lease:
        return await asyncio.to_thread(
            _native_upload_dataset_response,
            native_path_lease,
        )
    if file is None:
        raise HTTPException(status_code = 400, detail = "No dataset file was provided")

    filename, stored_path, max_bytes, max_label = _upload_destination(
        file.filename or "dataset_upload"
    )
    declared_size = getattr(file, "size", None)
    if isinstance(declared_size, int) and declared_size > max_bytes:
        raise _upload_too_large(max_label)

    written = 0
    upload_complete = False
    try:
        with open(stored_path, "wb") as f:
            while chunk := await file.read(LOCAL_UPLOAD_CHUNK_BYTES):
                written += len(chunk)
                if written > max_bytes:
                    raise _upload_too_large(max_label)
                await asyncio.to_thread(f.write, chunk)
        upload_complete = True

View on GitHub (pinned to 203007d190)

Solutions

  1. Send multipart/form-data with the field named exactly `file` (or use the native_path_lease flow for local files).
  2. Disable the upload button until a file is selected.
  3. Inspect the outgoing request in devtools to confirm the part name and content-type.
  4. For programmatic clients, assert the FormData has one entry before posting.

Example fix

# before
requests.post(url, json={"filename": "a.csv"})
# after
requests.post(url, files={"file": open("a.csv", "rb")})
Defensive patterns

Strategy: validation

Validate before calling

const fd = new FormData();
if (!(file instanceof File)) { showError('Select a file first'); return; }
fd.append('file', file);  // field name MUST be 'file'
fetch(url, { method: 'POST', body: fd });  // never set Content-Type manually

Type guard

function hasUploadPart(form: FormData): form is FormData & { get('file'): File } {
  const v = form.get('file');
  return v instanceof File;
}

Prevention

When it happens

Trigger: POSTing the upload endpoint with an empty body, wrong field name (not `file`), or a JSON body instead of multipart/form-data; a frontend bug sending the request before the File object is set.

Common situations: Fetch/axios call missing the FormData so the field never attaches; field renamed in a refactor; user clicks Upload with no file chosen and the client does not guard it.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/194a6e32793d2b54. Report an issue: GitHub.