{"record":{"id":"1b4aa6077aa208c5","repo":"dotnet/aspnetcore","slug":"failed-to-download-url-status-code-response-s","errorCode":null,"errorMessage":"Failed to download {url}, Status Code: {response.status}","messagePattern":"Failed to download (.+?), Status Code: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/common/cross/install-debs.py","lineNumber":40,"sourceCode":"    attempt = 0\n    while attempt < max_retries:\n        try:\n            async with session.get(url, timeout=aiohttp.ClientTimeout(total=timeout)) as response:\n                if response.status == 200:\n                    with open(dest_path, \"wb\") as f:\n                        content = await response.read()\n\n                        # verify checksum if provided\n                        if checksum:\n                            sha256 = hashlib.sha256(content).hexdigest()\n                            if sha256 != checksum:\n                                raise Exception(f\"SHA256 mismatch for {url}: expected {checksum}, got {sha256}\")\n\n                        f.write(content)\n                    print(f\"Downloaded {url} at {dest_path}\")\n                    return\n                else:\n                    raise Exception(f\"Failed to download {url}, Status Code: {response.status}\")\n        except (asyncio.CancelledError, asyncio.TimeoutError, aiohttp.ClientError) as e:\n            print(f\"Error downloading {url}: {type(e).__name__} - {e}. Retrying...\")\n\n        attempt += 1\n        await asyncio.sleep(retry_delay)\n\n    raise Exception(f\"Failed to download {url} after {max_retries} attempts.\")\n\nasync def download_deb_files_parallel(mirror, packages, tmp_dir):\n    \"\"\"Download .deb files in parallel.\"\"\"\n    os.makedirs(tmp_dir, exist_ok=True)\n\n    tasks = []\n    timeout = aiohttp.ClientTimeout(total=60)\n    async with aiohttp.ClientSession(timeout=timeout) as session:\n        for pkg, info in packages.items():\n            filename = info.get(\"Filename\")\n            if filename:","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/eng/common/cross/install-debs.py#L22-L58","documentation":"Raised by download_file when aiohttp returns a non-200 HTTP status for the requested URL. It captures the upstream status code so the operator can tell a 404 (wrong path) from a 403 (forbidden) or 5xx (server fault). Because it is raised inside the try, transient network errors are retried, but HTTP-level non-200 responses are not (they raise straight to the caller).","triggerScenarios":"session.get(url) returns a response whose .status is not 200 (404 for a package the index doesn't actually carry at that path, 403 from a firewall, 502/503 from an overloaded mirror).","commonSituations":"Stale Packages index referencing a .deb that was rotated off the mirror; wrong --arch (e.g. arm64 index pointing at a path only present for amd64); suite name typo; mirror with selective component availability (no 'universe'); geoblocking returning 403.","solutions":["Open the printed URL in a browser or curl -I to confirm the status code and adjust --mirror/--suite/--arch accordingly.","If 404, regenerate by pointing to a suite that still hosts the file (older stable point releases get archived under http://archive.debian.org).","If 403/451, switch mirrors or networks to bypass filtering.","If 5xx, retry shortly or fall back to a different mirror; do not change the script — the mirror is the fault."],"exampleFix":"# before\npython3 install-debs.py --mirror http://ftp.debian.org/debian --suite buster --arch amd64 --rootfsdir rootfs libc6\n# HTTP 404: buster moved to archive\n\n# after\npython3 install-debs.py --mirror http://archive.debian.org/debian --suite buster --arch amd64 --rootfsdir rootfs libc6","handlingStrategy":"validation","validationCode":"# Validate the URL exists before the run for any package you care about:\nfor pkg in libc6 libc-bin; do\n  url=\"$MIRROR/$(curl -fsS \"$MIRROR/dists/$SUITE/main/binary-$ARCH/Packages.gz\" | gzip -d | awk -v p=$pkg '$1==\"Package:\"{n=$2} $1==\"Filename:\"&&n==p{print $2}')\"\n  curl -fsS --head \"$url\" | head -1\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm the --suite is still on the primary mirror; archived releases move to archive.debian.org.","Match --arch to a path the mirror actually hosts.","If behind a filtering proxy, request allow-listing for the mirror host."],"tags":["python","network","http","debian","cross-build"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}