infiniflow/ragflow · error · Exception
TXT generation failed: {str(e)}
Error message
TXT generation failed: {str(e)} What it means
Catch-all wrapper thrown by DocGenerator._generate_txt (agent/component/docs_generator.py): the pandoc text conversion markdown->plain raised, and it is re-raised as Exception('TXT generation failed: <inner message>'). TXT is the simplest path, so failures almost always mean pandoc itself is unavailable or the input markdown triggers a parser error.
Source
Thrown at agent/component/docs_generator.py:633
def _generate_docx(self, content: str) -> tuple[str, bytes]:
try:
file_path, _ = self._generate_pandoc_binary_output(
content,
"docx",
"docx",
include_timestamp_in_body=False,
extra_args=["--standalone"],
)
return self._decorate_docx(file_path)
except Exception as e:
raise Exception(f"DOCX generation failed: {str(e)}")
def _generate_txt(self, content: str) -> tuple[str, bytes]:
try:
return self._generate_pandoc_text_output(content, "plain", "txt")
except Exception as e:
raise Exception(f"TXT generation failed: {str(e)}")
def _generate_markdown(self, content: str) -> tuple[str, bytes]:
try:
return self._generate_pandoc_text_output(content, "markdown", "md")
except Exception as e:
raise Exception(f"Markdown generation failed: {str(e)}")
def _generate_html(self, content: str) -> tuple[str, bytes]:
try:
return self._generate_pandoc_text_output(content, "html", "html")
except Exception as e:
raise Exception(f"HTML generation failed: {str(e)}")
View on GitHub (pinned to 554fb1133a)
Solutions
- Check the inner message after 'TXT generation failed:' — 'No pandoc was found' means install pandoc or pypandoc-binary
- Verify pandoc on the worker's PATH: pandoc --version
- Sanitize/validate the content string is valid UTF-8 before passing it in
- Reproduce manually: pandoc -f markdown -t plain input.md
Example fix
# before pip install pypandoc # wrapper only, no binary # after pip install pypandoc-binary # or apt-get install pandoc
Defensive patterns
Strategy: try-catch
Validate before calling
import shutil
def txt_prerequisites_ok():
return shutil.which('pandoc') is not None Try / catch
try:
file_path, file_bytes = generator._generate_txt(content)
except Exception as e:
inner = str(e).removeprefix('TXT generation failed: ')
if 'No pandoc was found' in inner:
raise RuntimeError('TXT output needs pandoc: apt-get install pandoc or pip install pypandoc-binary') from e
logger.error('TXT generation root cause: %s', inner)
raise Prevention
- Check pandoc availability before offering txt output
- Validate content is non-empty valid UTF-8 before generation
- Keep pandoc versions consistent between dev and production images
When it happens
Trigger: Running DocGenerator with output_format 'txt' when pypandoc cannot find the pandoc binary (OSError: No pandoc was found), pandoc exits non-zero on malformed input, or the output write path fails. Raised from the except around _generate_pandoc_text_output(content, 'plain', 'txt').
Common situations: Deployments that installed pypandoc (the wrapper) but not pandoc or pypandoc-binary; PATH differences between the shell used to install and the service runtime; content with encoding issues (lone surrogates, invalid UTF-8).
Related errors
- PDF generation failed: {str(e)}
- DOCX generation failed: {str(e)}
- Markdown generation failed: {str(e)}
- HTML generation failed: {str(e)}
- Document file is empty
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/2c04cd08f13e9767.
Report an issue: GitHub.