{"record":{"id":"390ca5e00155fcef","repo":"github/copilot-sdk","slug":"failed-to-download-from-url-last-exc","errorCode":null,"errorMessage":"Failed to download from {url}: {last_exc}","messagePattern":"Failed to download from (.+?): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/copilot/_cli_download.py","lineNumber":248,"sourceCode":"            if cached is not None:\n                return cached\n        raise\n\n    return str(binary_path)\n\n\ndef _fetch_url_bytes(url: str, *, timeout: int) -> bytes:\n    \"\"\"Download bytes from ``url`` with retries.\"\"\"\n    last_exc: Exception | None = None\n    for attempt in range(_MAX_RETRIES):\n        try:\n            with urlopen(url, timeout=timeout) as response:\n                return response.read()\n        except _RETRIABLE_DOWNLOAD_ERRORS as exc:\n            last_exc = exc\n            if attempt < _MAX_RETRIES - 1:\n                time.sleep(2**attempt)\n    raise RuntimeError(f\"Failed to download from {url}: {last_exc}\") from last_exc\n\n\n_HOSTLESS_EXCLUDED_TOP_LEVEL = {\n    \"app.js\",\n    \"assets\",\n    \"changelog.json\",\n    \"copilot\",\n    \"copilot.exe\",\n    \"copilot-sdk\",\n    \"foundry-local-sdk\",\n    \"index.js\",\n    \"LICENSE.md\",\n    \"napi-oop-runtime\",\n    \"npm-loader.js\",\n    \"package.json\",\n    \"preloads\",\n    \"pvrecorder\",\n    \"queries\",","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/python/copilot/_cli_download.py#L230-L266","documentation":"_fetch_url_bytes performs HTTP downloads with bounded retries for transient errors. After exhausting _MAX_RETRIES attempts, it wraps the last exception in this RuntimeError identifying the URL that could not be downloaded.","triggerScenarios":"Any download of the checksum file or release package (via _fetch_checksums or _fetch_verified_release_package) that fails on every retry — DNS failure, connection reset, TLS error, timeouts, or persistent 5xx responses.","commonSituations":"Corporate proxies/firewalls blocking github.com downloads; offline or flaky CI networks; GitHub release CDN outages; very slow links exceeding the timeout.","solutions":["Check network connectivity and proxy settings (HTTPS_PROXY/HTTP_PROXY).","Retry later — transient GitHub/CDN outages resolve; the library already retries with exponential backoff.","Manually download the asset and use COPILOT_CLI_PATH to point at a local binary.","Increase reliability of CI by caching the runtime bundle between jobs."],"exampleFix":"# before\n$ python -m copilot  # behind corporate proxy, no env set\n# after\n$ export HTTPS_PROXY=http://proxy.corp.example:3128\n$ python -m copilot","handlingStrategy":"retry","validationCode":"import urllib.request\ntry:\n    urllib.request.urlopen(\"https://github.com\", timeout=5)\nexcept OSError as e:\n    raise SystemExit(f\"network unavailable before download: {e}\")","typeGuard":null,"tryCatchPattern":"import time\nfor attempt in range(5):\n    try:\n        return download_cli()\n    except RuntimeError as e:\n        if \"Failed to download\" not in str(e) or attempt == 4:\n            raise\n        time.sleep(2 ** attempt)","preventionTips":["Configure proxy env vars in restricted networks.","Cache the runtime bundle in CI between runs.","Monitor GitHub status for download outages."],"tags":["network","http","download","retry"],"backgroundTag":"http-request-failed","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}