{"record":{"id":"e85bb363ba67479a","repo":"open-webui/open-webui","slug":"file-upload-to-presigned-url-timed-out","errorCode":null,"errorMessage":"File upload to presigned URL timed out","messagePattern":"File upload to presigned URL timed out","errorType":"http","errorClass":"HTTPException","httpStatus":504,"severity":"error","filePath":"backend/open_webui/retrieval/loaders/mineru.py","lineNumber":308,"sourceCode":"\n    def _upload_to_presigned_url(self, upload_url: str) -> None:\n        \"\"\"\n        Upload file to presigned URL (no authentication needed).\n        \"\"\"\n        log.info(f'Uploading file to presigned URL')\n\n        try:\n            with open(self.file_path, 'rb') as f:\n                response = requests.put(\n                    upload_url,\n                    data=f,\n                    timeout=self.timeout,\n                )\n                response.raise_for_status()\n        except FileNotFoundError:\n            raise HTTPException(status.HTTP_404_NOT_FOUND, detail=f'File not found: {self.file_path}')\n        except requests.Timeout:\n            raise HTTPException(\n                status.HTTP_504_GATEWAY_TIMEOUT,\n                detail='File upload to presigned URL timed out',\n            )\n        except requests.HTTPError as e:\n            raise HTTPException(\n                status.HTTP_400_BAD_REQUEST,\n                detail=f'Failed to upload file to presigned URL: {e}',\n            )\n        except Exception as e:\n            raise HTTPException(\n                status.HTTP_500_INTERNAL_SERVER_ERROR,\n                detail=f'Error uploading file: {str(e)}',\n            )\n\n        log.info('File uploaded successfully')\n\n    def _poll_batch_status(self, batch_id: str, filename: str) -> dict:\n        \"\"\"","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/open-webui/open-webui/blob/01f4282f1ffe0d6212f58d3afbeae21fffd0c4be/backend/open_webui/retrieval/loaders/mineru.py#L290-L326","documentation":"Raised as HTTP 504 when the PUT of the file body to the presigned URL exceeds self.timeout (default 300 s). Unlike the batch call, the upload throughput is bounded by your uplink and the storage backend (OSS presigned PUT), so big files on slow links are the main driver; presigned URLs also expire, and expiry can manifest as either this or an HTTP error.","triggerScenarios":"Uploading a multi-hundred-MB scanned PDF over a slow uplink where elapsed time passes self.timeout; saturated upstream bandwidth; storage endpoint in a distant region adding latency.","commonSituations":"Office uplink ~10 Mbps uploading 500 MB files; timeout left at default while document sizes grew; Wi-Fi/VPN links with erratic throughput.","solutions":["Increase the timeout parameter for large files (600-1200 s)","Compress/downsample oversized scans before parsing","Check uplink utilization during the upload window","If the URL expired before the transfer started, re-run to obtain a fresh presigned URL"],"exampleFix":"// before\nloader = MinerULoader(file_path=big_pdf, api_mode='cloud', api_key=key, timeout=300)\n\n// after\nloader = MinerULoader(file_path=big_pdf, api_mode='cloud', api_key=key, timeout=1200)","handlingStrategy":"retry","validationCode":"import os\nsize_mb = os.path.getsize(path) / 1e6\nuplink_mbps = measure_uplink()  # periodic speed probe\nest_s = size_mb * 8 / max(1, uplink_mbps)\nassert timeout_sec > est_s * 2, f'timeout {timeout_sec}s too small for {size_mb:.0f} MB'","typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        docs = loader.load()\n        break\n    except HTTPException as e:\n        if e.status_code == 504 and 'presigned URL timed out' in e.detail and attempt == 0:\n            continue  # fresh URL + fresh timeout on retry\n        raise","preventionTips":["Scale timeout with file size; big scans are not 300 s uploads","Compress oversized scanned PDFs before sending","Monitor uplink saturation during bulk ingestion windows"],"tags":["mineru","cloud-api","timeout","upload","network"],"backgroundTag":null,"analyzedSha":"01f4282f1ffe0d6212f58d3afbeae21fffd0c4be","analyzedAt":"2026-08-14T18:25:22.715Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}