{"record":{"id":"098e11d9cabc880c","repo":"oraios/serena","slug":"error-downloading-file","errorCode":null,"errorMessage":"Error downloading file.","messagePattern":"Error downloading file\\.","errorType":"exception","errorClass":"SolidLSPException","httpStatus":null,"severity":"error","filePath":"src/solidlsp/ls_utils.py","lineNumber":461,"sourceCode":"        expected_sha256: str | None = None,\n        allowed_hosts: Sequence[str] | None = None,\n    ) -> None:\n        \"\"\"\n        Downloads a file from ``url`` to ``target_path`` with optional integrity and host validation.\n        \"\"\"\n        # validating the requested host\n        FileUtils._validate_download_host(url, allowed_hosts)\n\n        # streaming the download into a temporary file\n        target_directory = os.path.dirname(target_path) or \".\"\n        os.makedirs(target_directory, exist_ok=True)\n        temp_file_path = str(PurePath(target_directory, f\".{Path(target_path).name}.{uuid.uuid4().hex}.download\"))\n        response: requests.Response | None = None\n        try:\n            response = requests.get(url, stream=True, timeout=60)\n            if response.status_code != 200:\n                log.error(f\"Error downloading file '{url}': {response.status_code} {response.text}\")\n                raise SolidLSPException(\"Error downloading file.\")\n\n            FileUtils._validate_download_host(response.url, allowed_hosts)\n\n            with open(temp_file_path, \"wb\") as output_file:\n                for chunk in response.iter_content(chunk_size=1024 * 1024):\n                    if chunk:\n                        output_file.write(chunk)\n\n            FileUtils._verify_sha256_if_configured(temp_file_path, expected_sha256)\n\n            os.replace(temp_file_path, target_path)\n        except Exception as exc:\n            log.error(f\"Error downloading file '{url}': {exc}\")\n            raise SolidLSPException(\"Error downloading file.\") from None\n        finally:\n            if response is not None:\n                response.close()\n            if os.path.exists(temp_file_path):","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/ls_utils.py#L443-L479","documentation":"SolidLSPException raised by FileUtils.download_file_verified (src/solidlsp/ls_utils.py:461) when the HTTP response for a language-server download has a status code other than 200. The status and body are logged; the public message is deliberately generic.","triggerScenarios":"Downloading a language server/runtime archive or auxiliary file when the URL 404s (version removed/renamed), returns 403 (blocked/rate-limited), or 5xx from the CDN/host.","commonSituations":"Pinned download URLs broken after upstream release changes; corporate proxies intercepting with non-200 responses; GitHub rate limiting; retired binary hosting locations.","solutions":["Check the logged status code and URL in the error output to see whether it's 404/403/5xx.","Update to a library version whose download URLs point at existing releases.","Retry later if rate-limited (403/429) or use an authenticated mirror.","Manually download the artifact to the expected target path to bypass the download step."],"exampleFix":"// before\nFileUtils.download_file_verified(url, target_dir)  # url 404s\n// after\nresp = requests.head(url, timeout=60)\nif resp.status_code != 200:\n    url = fallback_mirror_url(version)\nFileUtils.download_file_verified(url, target_dir)","handlingStrategy":"retry","validationCode":"def url_reachable(url: str) -> bool:\n    try:\n        return requests.head(url, timeout=10, allow_redirects=True).status_code == 200\n    except requests.RequestException:\n        return False","typeGuard":"def is_download_status_error(exc: BaseException) -> bool:\n    return isinstance(exc, SolidLSPException) and str(exc) == \"Error downloading file.\"","tryCatchPattern":"for delay in (1, 5, 30):\n    try:\n        FileUtils.download_file_verified(url, target_dir)\n        break\n    except SolidLSPException:\n        time.sleep(delay)\nelse:\n    raise RuntimeError(f\"download kept failing: {url}\")","preventionTips":["Pre-check download URLs (HEAD request) in setup scripts","Keep library versions updated so pinned URLs stay valid","Handle corporate proxies and rate limits with backoff","Mirror artifacts internally for reproducible installs"],"tags":["network","download","http"],"backgroundTag":"download-http-error","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}