{"record":{"id":"352fb12b7d5b8959","repo":"assafelovic/gpt-researcher","slug":"failed-to-load-any-documents-352fb1","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/online_document.py","lineNumber":34,"sourceCode":"\nclass OnlineDocumentLoader:\n\n    def __init__(self, urls):\n        self.urls = urls\n\n    async def load(self) -> list:\n        docs = []\n        for url in self.urls:\n            pages = await self._download_and_process(url)\n            for page in pages:\n                if page.page_content:\n                    docs.append({\n                        \"raw_content\": page.page_content,\n                        \"url\": page.metadata.get(\"source\")\n                    })\n\n        if not docs:\n            raise ValueError(\"🤷 Failed to load any documents!\")\n\n        return docs\n\n    async def _download_and_process(self, url: str) -> list:\n        try:\n            # Reject SSRF / local-file targets before issuing the request.\n            try:\n                validate_url(url)\n            except UnsafeURLError as e:\n                print(f\"Skipping unsafe document URL {url}: {e}\")\n                return []\n\n            headers = {\n                \"User-Agent\": \"Mozilla/5.0\"\n            }\n            async with aiohttp.ClientSession() as session:\n                async with session.get(url, headers=headers, timeout=6) as response:\n                    if response.status != 200:","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/assafelovic/gpt-researcher/blob/6f998577d547b1e54ec662dac63583aa11e3b84b/gpt_researcher/document/online_document.py#L16-L52","documentation":"OnlineDocumentLoader.load fetches documents from URLs; if no URL produced any parsed content (all downloads/parses failed or the list was empty), docs is empty and this ValueError is raised.","triggerScenarios":"Passing URLs that 404/timeout, HTML pages with no extractable text, non-document content-types, or an empty list of sources.","commonSituations":"Scraped links behind auth/JS rendering; typo'd URLs; sources returning HTML error pages that parse to nothing.","solutions":["Check each URL returns 200 and real content (curl/browser) before loading","Filter out non-document links; verify at least one source is a parseable doc","Handle per-URL failures upstream and require >=1 valid source before calling load"],"exampleFix":"# before\nloader = OnlineDocumentLoader(['https://example.com/missing.pdf'])\n# after\nvalid = [u for u in urls if requests.head(u, timeout=10).ok]\nif not valid: raise SystemExit('no valid sources')\nloader = OnlineDocumentLoader(valid)","handlingStrategy":"validation","validationCode":"import requests\nok = [u for u in urls if u.startswith('http') and requests.head(u, timeout=10, allow_redirects=True).status_code < 400]\nassert ok, 'no reachable document URLs'","typeGuard":null,"tryCatchPattern":"try:\n    docs = loader.load()\nexcept ValueError as e:\n    if \"Failed to load any documents\" in str(e):\n        docs = fallback_scrape(urls)\n    else: raise","preventionTips":["Preflight URLs with HEAD requests","Drop non-document links before loading"],"tags":["python","document-loader","web-scraping","empty-input"],"backgroundTag":"no-documents-loaded","analyzedSha":"6f998577d547b1e54ec662dac63583aa11e3b84b","analyzedAt":"2026-08-28T17:50:07.383Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}