{"record":{"id":"3a479ca940179d11","repo":"iflytek/astron-agent","slug":"downloaded-file-is-empty","errorCode":null,"errorMessage":"Downloaded file is empty","messagePattern":"Downloaded file is empty","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"core/knowledge/infra/ragflow/ragflow_utils.py","lineNumber":204,"sourceCode":"        Returns:\n            (file content, filename)\n        \"\"\"\n        logger.info(f\"Downloading file from URL: {file}\")\n\n        async with aiohttp.ClientSession() as session:\n            async with session.get(file) as response:\n                if response.status != 200:\n                    raise Exception(f\"File download failed: HTTP {response.status}\")\n\n                file_content = await response.read()\n                logger.info(f\"Download completed: {len(file_content)} bytes\")\n\n                # Get filename\n                filename = RagflowUtils._extract_filename_from_url(file, response)\n\n                # Validate downloaded content\n                if len(file_content) == 0:\n                    raise Exception(\"Downloaded file is empty\")\n\n                return file_content, filename\n\n    @staticmethod\n    def _extract_filename_from_url(file: str, response: Any) -> str:\n        \"\"\"\n        Extract filename from URL or response\n\n        Args:\n            file: Original URL\n            response: HTTP response object\n\n        Returns:\n            Extracted filename\n        \"\"\"\n        filename = None\n\n        # First try to get filename from HTTP response headers","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/infra/ragflow/ragflow_utils.py#L186-L222","documentation":"Raised in RagflowUtils._download_url_file when a remote file fetched over HTTP arrives with zero bytes. It is a generic sentinel-style guard placed after `await response.read()`: the HTTP status was 200 (success), but the body contained no data, so the downloaded payload cannot be a valid document. The at-fault input is the `file` URL being downloaded — it points to a resource that resolves to an empty body, typically because the object storage object or upstream link is empty, was truncated by a proxy/redirect, or the URL no longer maps to real content. The function treats an empty download as unusable and aborts rather than passing empty bytes on to RAGFlow ingestion, which would otherwise produce a broken or meaningless knowledge-base document.","triggerScenarios":"Thrown at core/knowledge/infra/ragflow/ragflow_utils.py:204 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the source URL actually serves file content","Check for redirect-to-empty or range-request issues","Reject the upload early with a clear user-facing message"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}