unslothai/unsloth · error · HTTPException

Unsupported file format: {dataset_path.suffix}

Error message

Unsupported file format: {dataset_path.suffix}

What it means

HTTP 400 from local preview when the selected file's lowercased suffix is neither .parquet (exact-count branch), .json/.jsonl/.csv (stream branch) — i.e. the file passed directory candidate selection but has an extension the per-file loader does not handle. This is the terminal fallthrough of the format ladder, so any exotic suffix lands here.

Source

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

    suffix = dataset_path.suffix.lower()
    # Parquet/Arrow give a cheap exact total_rows; JSON/CSV carry none, so stream and report None.
    if suffix == ".parquet":
        dataset = load_dataset("parquet", data_files = str(dataset_path), split = train_split)
        total_rows = len(dataset)
        preview_slice = dataset.select(range(min(preview_size, total_rows)))
        return preview_slice, total_rows

    if suffix in (".json", ".jsonl", ".csv"):
        preview = _stream_file_preview_slice(dataset_path, preview_size)
        if preview is None:
            raise HTTPException(
                status_code = 400,
                detail = "Dataset appears to be empty or could not be read",
            )
        return preview

    raise HTTPException(status_code = 400, detail = f"Unsupported file format: {dataset_path.suffix}")


def _sanitize_filename(filename: str) -> str:
    name = Path(filename).name.strip().replace("\x00", "")
    if not name:
        return "dataset_upload"
    return name


def _upload_too_large(limit_label: str) -> HTTPException:
    return HTTPException(
        status_code = 413,
        detail = f"Training dataset upload too large. Maximum is {limit_label}.",
    )


def _upload_destination(filename: str) -> tuple[str, Path, int, str]:
    filename = _sanitize_filename(filename)

View on GitHub (pinned to 203007d190)

Solutions

  1. Convert the file to one of parquet/json/jsonl/csv before previewing.
  2. For .tsv, rename/save as .csv with comma separators (or convert properly with pandas).
  3. For .arrow, convert with pyarrow to parquet.
  4. Check the reported suffix in the detail message — occasionally a double extension like data.parquet.csv is the real culprit.

Example fix

# pandas convert before preview
import pandas as pd
pd.read_excel("sales.xlsx").to_parquet("sales.parquet")
Defensive patterns

Strategy: type-guard

Validate before calling

SUPPORTED = {".parquet", ".json", ".jsonl", ".csv"}

def suffix_ok(path: Path) -> bool:
    return path.suffix.lower() in SUPPORTED

Type guard

def is_supported_file(path: Path) -> TypeGuard[Path]:
    return path.is_file() and path.suffix.lower() in {".parquet", ".json", ".jsonl", ".csv"}

Prevention

When it happens

Trigger: Previewing a single file with suffixes like .arrow, .tsv, .xlsx, .txt, or no suffix; a path whose stem contains dots confusing naive clients (suffix itself is still checked correctly).

Common situations: Users dropping Excel exports (.xlsx) or TSV files and expecting preview; datasets tools exporting .arrow shards; case variants are handled (.PARQUET works) but format variants are not.

Related errors


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