{"record":{"id":"8ed6b6f4ff617d9b","repo":"infiniflow/ragflow","slug":"html-generation-failed-str-e","errorCode":null,"errorMessage":"HTML generation failed: {str(e)}","messagePattern":"HTML generation failed: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"agent/component/docs_generator.py","lineNumber":645,"sourceCode":"            raise Exception(f\"DOCX generation failed: {str(e)}\")\n\n    def _generate_txt(self, content: str) -> tuple[str, bytes]:\n        try:\n            return self._generate_pandoc_text_output(content, \"plain\", \"txt\")\n        except Exception as e:\n            raise Exception(f\"TXT generation failed: {str(e)}\")\n\n    def _generate_markdown(self, content: str) -> tuple[str, bytes]:\n        try:\n            return self._generate_pandoc_text_output(content, \"markdown\", \"md\")\n        except Exception as e:\n            raise Exception(f\"Markdown generation failed: {str(e)}\")\n\n    def _generate_html(self, content: str) -> tuple[str, bytes]:\n        try:\n            return self._generate_pandoc_text_output(content, \"html\", \"html\")\n        except Exception as e:\n            raise Exception(f\"HTML generation failed: {str(e)}\")\n","sourceCodeStart":627,"sourceCodeEnd":646,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/component/docs_generator.py#L627-L646","documentation":"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.","triggerScenarios":"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').","commonSituations":"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.","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"],"exampleFix":"# environment fix\npip install pypandoc-binary   # or ensure 'pandoc' resolves on the worker's PATH","handlingStrategy":"try-catch","validationCode":"import shutil\n\ndef html_prerequisites_ok():\n    return shutil.which('pandoc') is not None","typeGuard":null,"tryCatchPattern":"try:\n    file_path, file_bytes = generator._generate_html(content)\nexcept Exception as e:\n    inner = str(e).removeprefix('HTML generation failed: ')\n    logger.error('HTML generation root cause: %s', inner)\n    raise","preventionTips":["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"],"tags":["doc-generator","pandoc","runtime","error-wrapping"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}