{"record":{"id":"529f5842936ef51d","repo":"infiniflow/ragflow","slug":"markdown-generation-failed-str-e","errorCode":null,"errorMessage":"Markdown generation failed: {str(e)}","messagePattern":"Markdown generation failed: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"agent/component/docs_generator.py","lineNumber":639,"sourceCode":"                \"docx\",\n                include_timestamp_in_body=False,\n                extra_args=[\"--standalone\"],\n            )\n            return self._decorate_docx(file_path)\n        except Exception as e:\n            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":621,"sourceCodeEnd":646,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/component/docs_generator.py#L621-L646","documentation":"Catch-all wrapper thrown by DocGenerator._generate_markdown (agent/component/docs_generator.py): the pandoc markdown->markdown round-trip (used to normalize the content, strip templates, add a timestamp) raised and is re-raised as Exception('Markdown generation failed: <inner message>'). The inner exception carries the actual cause, typically pandoc availability or parse errors.","triggerScenarios":"Running DocGenerator with output_format 'markdown' when pandoc is missing (pypandoc OSError), input content has constructs the markdown reader rejects, or the temp output write fails. Raised from the except around _generate_pandoc_text_output(content, 'markdown', 'md').","commonSituations":"Same class as TXT: missing pandoc binary in the runtime environment; content with mixed/invalid encodings; pandoc version changes to extension handling; read-only temp directories.","solutions":["Read the appended inner message to get the root cause","Install pandoc (apt-get install pandoc) or pip install pypandoc-binary so the conversion can run","Ensure TMPDIR is writable and large enough for the output","Pre-validate the content is non-empty valid UTF-8 markdown"],"exampleFix":"# environment fix\nsudo apt-get install -y pandoc   # Debian/Ubuntu; verify with: pandoc --version","handlingStrategy":"try-catch","validationCode":"import shutil\n\ndef markdown_prerequisites_ok():\n    return shutil.which('pandoc') is not None","typeGuard":null,"tryCatchPattern":"try:\n    file_path, file_bytes = generator._generate_markdown(content)\nexcept Exception as e:\n    inner = str(e).removeprefix('Markdown generation failed: ')\n    logger.error('Markdown generation root cause: %s', inner)\n    raise","preventionTips":["Ensure pandoc is installed in the worker environment, not just locally","Pre-validate content encoding before feeding the generator","Watch pandoc extension behavior when upgrading versions"],"tags":["doc-generator","pandoc","runtime","error-wrapping"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}