{"record":{"id":"65ab5f20c4e9088e","repo":"assafelovic/gpt-researcher","slug":"failed-to-load-any-documents","errorCode":null,"errorMessage":"🤷 Failed to load any documents!","messagePattern":"🤷 Failed to load any documents!","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"gpt_researcher/document/document.py","lineNumber":60,"sourceCode":"\n        # for root, dirs, files in os.walk(self.path):\n        #     for file in files:\n        #         file_path = os.path.join(root, file)\n        #         file_name, file_extension_with_dot = os.path.splitext(file_path)\n        #         file_extension = file_extension_with_dot.strip(\".\")\n        #         tasks.append(self._load_document(file_path, file_extension))\n\n        docs = []\n        for pages in await asyncio.gather(*tasks):\n            for page in pages:\n                if page.page_content:\n                    docs.append({\n                        \"raw_content\": page.page_content,\n                        \"url\": os.path.basename(page.metadata['source'])\n                    })\n                    \n        if not docs:\n            raise ValueError(\"🤷 Failed to load any documents!\")\n\n        return docs\n\n    async def _load_document(self, file_path: str, file_extension: str) -> list:\n        ret_data = []\n        try:\n            loader_dict = {\n                \"pdf\": PyMuPDFLoader(file_path),\n\"epub\": UnstructuredEPubLoader(file_path),\n                \"txt\": TextLoader(file_path),\n                \"doc\": UnstructuredWordDocumentLoader(file_path),\n                \"docx\": UnstructuredWordDocumentLoader(file_path),\n                \"pptx\": UnstructuredPowerPointLoader(file_path),\n                \"csv\": UnstructuredCSVLoader(file_path, mode=\"elements\"),\n                \"xls\": UnstructuredExcelLoader(file_path, mode=\"elements\"),\n                \"xlsx\": UnstructuredExcelLoader(file_path, mode=\"elements\"),\n                \"md\": UnstructuredMarkdownLoader(file_path),\n                \"html\": BSHTMLLoader(file_path),","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/assafelovic/gpt-researcher/blob/6f998577d547b1e54ec662dac63583aa11e3b84b/gpt_researcher/document/document.py#L42-L78","documentation":"After walking local paths and loading files, if zero documents were successfully produced (empty dir, unsupported extensions, or all _load_document calls failed), load raises this ValueError.","triggerScenarios":"Pointing DocumentLoader at an empty directory; a dir of .xyz files with no matching loader; all files failing to parse so docs stays empty.","commonSituations":"Wrong DOC_PATH; documents filtered out by extension; corrupt files silently skipped per-file.","solutions":["Verify the directory contains supported file types (pdf, txt, md, docx, html, ...)","Check the path exists and is the intended one; print os.listdir first","Look at earlier per-file warnings—files may be failing individually"],"exampleFix":"# before\nloader = DocumentLoader('./uploads')\n# after\nimport os\np = './uploads'\nassert os.path.isdir(p) and any(f.endswith(('.pdf','.txt','.md')) for f in os.listdir(p))\nloader = DocumentLoader(p)","handlingStrategy":"validation","validationCode":"import os\nEXTS = {'.pdf','.txt','.md','.docx','.html','.csv'}\nfiles = [f for f in os.listdir(path) if os.path.splitext(f)[1].lower() in EXTS]\nassert files, f\"no loadable documents in {path}\"","typeGuard":"def has_loadable_docs(path: str) -> bool:\n    return any(os.path.splitext(f)[1].lower in {'.pdf','.txt','.md','.docx'} for f in os.listdir(path))","tryCatchPattern":"try:\n    docs = loader.load()\nexcept ValueError as e:\n    if \"Failed to load any documents\" in str(e):\n        docs = []  # treat as empty corpus, degrade gracefully\n    else: raise","preventionTips":["Check dir contents/extensions before loading","Surface per-file warnings to spot silently skipped files"],"tags":["python","document-loader","empty-input"],"backgroundTag":"no-documents-loaded","analyzedSha":"6f998577d547b1e54ec662dac63583aa11e3b84b","analyzedAt":"2026-08-28T17:50:07.383Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}