infiniflow/ragflow · error · Exception
HTML generation failed: {str(e)}
Error message
HTML generation failed: {str(e)} What it means
Catch-all wrapper thrown by DocGenerator._generate_html (agent/component/docs_generator.py): the pandoc markdown->html conversion raised and is re-raised as Exception('HTML generation failed: <inner message>'). Like the other format wrappers, the meaningful diagnostic is the original exception text appended after the colon.
Source
Thrown at agent/component/docs_generator.py:645
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
- Inspect the text after 'HTML generation failed:' for the underlying exception
- Install pandoc or pypandoc-binary in the runtime image/environment
- Reproduce with: pandoc -f markdown -t html input.md
- Clean the content of encoding anomalies before feeding the component
Example fix
# environment fix pip install pypandoc-binary # or ensure 'pandoc' resolves on the worker's PATH
Defensive patterns
Strategy: try-catch
Validate before calling
import shutil
def html_prerequisites_ok():
return shutil.which('pandoc') is not None Try / catch
try:
file_path, file_bytes = generator._generate_html(content)
except Exception as e:
inner = str(e).removeprefix('HTML generation failed: ')
logger.error('HTML generation root cause: %s', inner)
raise Prevention
- Diagnose from the appended inner message
- Install pandoc/pypandoc-binary wherever DocGenerator runs
- Reproduce with pandoc -f markdown -t html to isolate content issues
- Sanitize raw HTML/encoding anomalies in generated content
When it happens
Trigger: Running DocGenerator with output_format 'html' when pandoc/pypandoc is unavailable, the markdown reader errors on the content, or writing the .html output to the temp directory fails. Raised from the except around _generate_pandoc_text_output(content, 'html', 'html').
Common situations: Missing pandoc binary in slim containers; content containing raw HTML/CDATA that trips the reader; non-UTF-8 bytes in generated content; temp-dir permission changes.
Related errors
- PDF generation failed: {str(e)}
- DOCX generation failed: {str(e)}
- TXT generation failed: {str(e)}
- Markdown generation failed: {str(e)}
- Document file is empty
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/8ed6b6f4ff617d9b.
Report an issue: GitHub.