unslothai/unsloth · error · HTTPException
Dataset appears to be empty or could not be streamed
Error message
Dataset appears to be empty or could not be streamed
What it means
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.
Source
Thrown at studio/backend/hub/services/datasets/formatting.py:440
if preview_slice is None:
# Tier 2: full streaming (resolves all files — slow for large repos)
logger.info("Tier 2: falling back to full streaming load_dataset")
try:
load_kwargs = {
"path": request.dataset_name,
"split": request.train_split or "train",
"streaming": True,
}
if request.subset:
load_kwargs["name"] = request.subset
if hf_token:
load_kwargs["token"] = hf_token
streamed_ds = load_dataset(**load_kwargs)
rows = list(islice(streamed_ds, PREVIEW_SIZE))
if not rows:
raise HTTPException(
status_code = 400,
detail = "Dataset appears to be empty or could not be streamed",
)
preview_slice = Dataset.from_list(rows)
total_rows = None
except Exception:
cached_preview = _load_any_cached_hf_preview_slice(
request,
PREVIEW_SIZE,
hf_token,
)
if cached_preview is None:
raise
preview_slice, total_rows = cached_preview
result = check_dataset_format(preview_slice, is_vlm = request.is_vlm)
View on GitHub (pinned to 203007d190)
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.
Example fix
# before req.train_split = "validation" # split with 0 rows # after req.train_split = "train" # non-empty split
Defensive patterns
Strategy: fallback
Validate before calling
files = list_repo_files(client, repo_id) # hub API
data_files = [f for f in files if f.endswith((".parquet", ".json", ".jsonl", ".csv"))]
if not data_files:
show_empty_dataset_warning() # streaming preview will 400; skip the call Try / catch
try:
preview = get_preview(client, req)
except HTTPStatusError as e:
if e.response.status_code == 400 and "empty" in e.response.text:
preview = try_full_download_preview(client, req) # fall back to non-streaming load
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid repo_id: {repo_id!r}
- dataset_local_cache_miss
- dataset_streaming requires a plain split name in {field_name
- dataset_name must be a Hugging Face repo id like org/repo
- dataset_streaming streams from the Hub and cannot use the lo
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/9ffa3ba4f7147e67.
Report an issue: GitHub.