{"record":{"id":"610b45090748544a","repo":"unslothai/unsloth","slug":"no-text-found-in-any-uploaded-files","errorCode":null,"errorMessage":"No text found in any uploaded files.","messagePattern":"No text found in any uploaded files\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/plugins/data-designer-unstructured-seed/src/data_designer_unstructured_seed/chunking.py","lineNumber":171,"sourceCode":"    cached = _CACHE_DIR / f\"{cache_key}.parquet\"\n    if cached.exists():\n        df = pd.read_parquet(cached)\n        rows = df.to_dict(orient = \"records\")\n        return cached, rows\n\n    all_rows: list[dict[str, str]] = []\n    for txt_path, orig_name in file_entries:\n        text = load_unstructured_text_file(txt_path)\n        chunks = split_text_into_chunks(\n            text = text,\n            chunk_size = chunk_size,\n            chunk_overlap = chunk_overlap,\n        )\n        for chunk in chunks:\n            all_rows.append({\"chunk_text\": chunk, \"source_file\": orig_name})\n\n    if not all_rows:\n        raise ValueError(\"No text found in any uploaded files.\")\n\n    df = pd.DataFrame(all_rows)\n    ensure_dir(_CACHE_DIR)\n    tmp = _CACHE_DIR / f\"{cache_key}.tmp.parquet\"\n    df.to_parquet(tmp, index = False)\n    tmp.replace(cached)\n    return cached, all_rows\n\n\ndef load_unstructured_text_file(path: Path) -> str:\n    ext = path.suffix.lower()\n    if ext not in {\".txt\", \".md\"}:\n        raise ValueError(f\"Unsupported unstructured seed file type: {ext}\")\n\n    raw = path.read_text(encoding = \"utf-8\", errors = \"ignore\")\n    return normalize_unstructured_text(raw)\n\n","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/plugins/data-designer-unstructured-seed/src/data_designer_unstructured_seed/chunking.py#L153-L189","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Inspect the extracted txt files server-side: for f in files: print(f, f.stat().st_size).","Fix or exclude extraction steps that produced empty outputs (e.g. OCR the scanned PDFs first).","Validate files client- and server-side for non-empty text before submitting the batch."],"exampleFix":"# before\nfile_entries = [(p, name) for p, name in all_uploads]  # some/all empty\n\n# after\nfile_entries = [(p, name) for p, name in all_uploads if p.stat().st_size > 0]\nassert file_entries, \"no non-empty uploads\"","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef batch_has_text(file_entries: list[tuple[Path, str]]) -> bool:\n    return any(p.is_file() and p.read_text(encoding=\"utf-8\", errors=\"ignore\").strip()\n               for p, _ in file_entries)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter out empty extraction artifacts before submitting a batch.","Surface per-file extraction sizes in the upload UI so users see which files contributed nothing."],"tags":["empty-file","validation","plugin","batch-upload"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}