{"record":{"id":"194a6e32793d2b54","repo":"unslothai/unsloth","slug":"no-dataset-file-was-provided","errorCode":null,"errorMessage":"No dataset file was provided","messagePattern":"No dataset file was provided","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"studio/backend/hub/services/datasets/local.py","lineNumber":364,"sourceCode":"                stored_path.unlink(missing_ok = True)\n\n    if written == 0:\n        stored_path.unlink(missing_ok = True)\n        raise HTTPException(status_code = 400, detail = \"Dropped dataset is empty\")\n\n    return UploadDatasetResponse(filename = filename, stored_path = str(stored_path))\n\n\nasync def upload_dataset_response(\n    file: UploadFile | None, native_path_lease: str | None = None\n) -> UploadDatasetResponse:\n    if native_path_lease:\n        return await asyncio.to_thread(\n            _native_upload_dataset_response,\n            native_path_lease,\n        )\n    if file is None:\n        raise HTTPException(status_code = 400, detail = \"No dataset file was provided\")\n\n    filename, stored_path, max_bytes, max_label = _upload_destination(\n        file.filename or \"dataset_upload\"\n    )\n    declared_size = getattr(file, \"size\", None)\n    if isinstance(declared_size, int) and declared_size > max_bytes:\n        raise _upload_too_large(max_label)\n\n    written = 0\n    upload_complete = False\n    try:\n        with open(stored_path, \"wb\") as f:\n            while chunk := await file.read(LOCAL_UPLOAD_CHUNK_BYTES):\n                written += len(chunk)\n                if written > max_bytes:\n                    raise _upload_too_large(max_label)\n                await asyncio.to_thread(f.write, chunk)\n        upload_complete = True","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/hub/services/datasets/local.py#L346-L382","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Send multipart/form-data with the field named exactly `file` (or use the native_path_lease flow for local files).","Disable the upload button until a file is selected.","Inspect the outgoing request in devtools to confirm the part name and content-type.","For programmatic clients, assert the FormData has one entry before posting."],"exampleFix":"# before\nrequests.post(url, json={\"filename\": \"a.csv\"})\n# after\nrequests.post(url, files={\"file\": open(\"a.csv\", \"rb\")})","handlingStrategy":"validation","validationCode":"const fd = new FormData();\nif (!(file instanceof File)) { showError('Select a file first'); return; }\nfd.append('file', file);  // field name MUST be 'file'\nfetch(url, { method: 'POST', body: fd });  // never set Content-Type manually","typeGuard":"function hasUploadPart(form: FormData): form is FormData & { get('file'): File } {\n  const v = form.get('file');\n  return v instanceof File;\n}","tryCatchPattern":null,"preventionTips":["Send multipart/form-data with the part named exactly `file`; do not send JSON to this endpoint.","Disable submit until a file is chosen.","Verify the outgoing request in devtools when uploads mysteriously 400."],"tags":["upload","multipart","validation","http-400"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}