unslothai/unsloth · error · ValueError

No text found in any uploaded files.

Error message

No text found in any uploaded files.

What it means

ValueError raised by the multi-file materialization path when a batch of uploaded files yielded zero total chunks. Each file is loaded (only .txt/.md are supported), normalized, and chunked; if every file contributes nothing — empty files, whitespace-only content — all_rows stays empty and the error fires before any parquet cache is written.

Source

Thrown at studio/backend/plugins/data-designer-unstructured-seed/src/data_designer_unstructured_seed/chunking.py:171

    cached = _CACHE_DIR / f"{cache_key}.parquet"
    if cached.exists():
        df = pd.read_parquet(cached)
        rows = df.to_dict(orient = "records")
        return cached, rows

    all_rows: list[dict[str, str]] = []
    for txt_path, orig_name in file_entries:
        text = load_unstructured_text_file(txt_path)
        chunks = split_text_into_chunks(
            text = text,
            chunk_size = chunk_size,
            chunk_overlap = chunk_overlap,
        )
        for chunk in chunks:
            all_rows.append({"chunk_text": chunk, "source_file": orig_name})

    if not all_rows:
        raise ValueError("No text found in any uploaded files.")

    df = pd.DataFrame(all_rows)
    ensure_dir(_CACHE_DIR)
    tmp = _CACHE_DIR / f"{cache_key}.tmp.parquet"
    df.to_parquet(tmp, index = False)
    tmp.replace(cached)
    return cached, all_rows


def load_unstructured_text_file(path: Path) -> str:
    ext = path.suffix.lower()
    if ext not in {".txt", ".md"}:
        raise ValueError(f"Unsupported unstructured seed file type: {ext}")

    raw = path.read_text(encoding = "utf-8", errors = "ignore")
    return normalize_unstructured_text(raw)

View on GitHub (pinned to 203007d190)

Solutions

  1. Inspect the extracted txt files server-side: for f in files: print(f, f.stat().st_size).
  2. Fix or exclude extraction steps that produced empty outputs (e.g. OCR the scanned PDFs first).
  3. Validate files client- and server-side for non-empty text before submitting the batch.

Example fix

# before
file_entries = [(p, name) for p, name in all_uploads]  # some/all empty

# after
file_entries = [(p, name) for p, name in all_uploads if p.stat().st_size > 0]
assert file_entries, "no non-empty uploads"
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

def batch_has_text(file_entries: list[tuple[Path, str]]) -> bool:
    return any(p.is_file() and p.read_text(encoding="utf-8", errors="ignore").strip()
               for p, _ in file_entries)

Prevention

When it happens

Trigger: Uploading a batch where every file is empty or whitespace-only, or where extraction produced only empty .txt artifacts (e.g. PDFs whose text extraction failed upstream and wrote empty txt files).

Common situations: Frontend upload handler created placeholder txt files for failed extractions; batch of scanned image-only PDFs that contain no extractable text; whitespace-only markdown files.

Related errors


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