{"record":{"id":"9ffa3ba4f7147e67","repo":"unslothai/unsloth","slug":"dataset-appears-to-be-empty-or-could-not-be-stream","errorCode":null,"errorMessage":"Dataset appears to be empty or could not be streamed","messagePattern":"Dataset appears to be empty or could not be streamed","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"studio/backend/hub/services/datasets/formatting.py","lineNumber":440,"sourceCode":"            if preview_slice is None:\n                # Tier 2: full streaming (resolves all files — slow for large repos)\n                logger.info(\"Tier 2: falling back to full streaming load_dataset\")\n                try:\n                    load_kwargs = {\n                        \"path\": request.dataset_name,\n                        \"split\": request.train_split or \"train\",\n                        \"streaming\": True,\n                    }\n                    if request.subset:\n                        load_kwargs[\"name\"] = request.subset\n                    if hf_token:\n                        load_kwargs[\"token\"] = hf_token\n\n                    streamed_ds = load_dataset(**load_kwargs)\n\n                    rows = list(islice(streamed_ds, PREVIEW_SIZE))\n                    if not rows:\n                        raise HTTPException(\n                            status_code = 400,\n                            detail = \"Dataset appears to be empty or could not be streamed\",\n                        )\n\n                    preview_slice = Dataset.from_list(rows)\n                    total_rows = None\n                except Exception:\n                    cached_preview = _load_any_cached_hf_preview_slice(\n                        request,\n                        PREVIEW_SIZE,\n                        hf_token,\n                    )\n                    if cached_preview is None:\n                        raise\n                    preview_slice, total_rows = cached_preview\n\n        result = check_dataset_format(preview_slice, is_vlm = request.is_vlm)\n","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/hub/services/datasets/formatting.py#L422-L458","documentation":"HTTP 400 raised when streaming preview succeeded in calling `load_dataset(streaming=True)` but `islice(streamed_ds, PREVIEW_SIZE)` yielded zero rows. The loader connected and opened the dataset, yet the first page of records was empty — so the dataset is effectively empty from the API's perspective or the stream could not produce rows.","triggerScenarios":"Previewing a genuinely empty hub dataset; a dataset whose train split has 0 rows; streaming over a flaky connection that returns an empty first page; a gated/revision mismatch where the resolved revision contains no data files.","commonSituations":"Newly created hub repos with metadata but no data pushed yet; wrong config/subset selected so the chosen split is empty; CDN serving an empty first shard.","solutions":["Verify on huggingface.co that the dataset's chosen config/split actually contains rows.","Retry the preview — transient empty first pages from the hub CDN do occur.","Try a different subset or train_split value that matches the dataset's README config.","If it persists, download the dataset fully and preview from local cache instead of streaming."],"exampleFix":"# before\nreq.train_split = \"validation\"  # split with 0 rows\n# after\nreq.train_split = \"train\"      # non-empty split","handlingStrategy":"fallback","validationCode":"files = list_repo_files(client, repo_id)  # hub API\ndata_files = [f for f in files if f.endswith((\".parquet\", \".json\", \".jsonl\", \".csv\"))]\nif not data_files:\n    show_empty_dataset_warning()  # streaming preview will 400; skip the call","typeGuard":null,"tryCatchPattern":"try:\n    preview = get_preview(client, req)\nexcept HTTPStatusError as e:\n    if e.response.status_code == 400 and \"empty\" in e.response.text:\n        preview = try_full_download_preview(client, req)  # fall back to non-streaming load\n    else:\n        raise","preventionTips":["Pre-check that the chosen config/split names exist in the dataset card before previewing.","Retry once on empty-stream results — transient CDN first pages happen.","Prefer fully-downloaded previews over streaming for unreliable networks."],"tags":["huggingface","streaming","empty-dataset","http-400","preview"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}