{"record":{"id":"a9bff1440165fbed","repo":"pypa/pip","slug":"incomplete-download","errorCode":"incomplete-download","errorMessage":"Download failed because not enough bytes were received ({download_status})","messagePattern":"Download failed because not enough bytes were received \\((.+?)\\)","errorType":"exception","errorClass":"IncompleteDownloadError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/network/download.py","lineNumber":279,"sourceCode":"\n            try:\n                resume_resp = self._http_get_resume(download, should_match=first_resp)\n                # Fallback: if the server responded with 200 (i.e., the file has\n                # since been modified or range requests are unsupported) or any\n                # other unexpected status, restart the download from the beginning.\n                must_restart = resume_resp.status_code != HTTPStatus.PARTIAL_CONTENT\n                if must_restart:\n                    download.reset_file()\n                    download.size = _get_http_response_size(resume_resp)\n                    first_resp = resume_resp\n                else:\n                    # If the resume request starts at the wrong location, fail\n                    # outright since the server is misbehaving.\n                    content_range = resume_resp.headers.get(\"Content-Range\", \"\")\n                    resumed_at = content_range.lower().partition(\"bytes \")[2]\n                    resumed_at = resumed_at.partition(\"-\")[0]\n                    if resumed_at and resumed_at != str(download.bytes_received):\n                        raise IncompleteDownloadError(download)\n\n                self._process_response(download, resume_resp)\n            except (\n                ConnectionFailedError,\n                ConnectionTimeoutError,\n                ProxyConnectionError,\n                SSLVerificationError,\n                ReadTimeoutError,\n                ProtocolError,\n                OSError,\n            ):\n                # The error handling here is tricky, a few notes:\n                #\n                # - The diagnostic connection errors are raised by our custom\n                #   requests.request() connection exception handler.\n                # - ProtocolError is raised by urllib3 when the returned data length\n                #   doesn't match the response Content-Length.\n                # - ReadTimeoutError / ProtocolError come straight from urllib3 (via","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/network/download.py#L261-L297","documentation":"Raised as IncompleteDownloadError inside _attempt_resumes_or_redownloads when, during a resume request, the server's 206 'Content-Range' header start byte does not equal the bytes already received. The server is misbehaving (returning a range at an unexpected offset), so pip aborts rather than write a corrupted file. Distinct from the exhaustion case: this fires on the first mismatched resume before retries run out.","triggerScenarios":"A resumable download is retried (--resume-retries>0); the server returns 206 Partial Content whose Content-Range 'bytes START-...' START differs from download.bytes_received (e.g. server restarted from 0, or rewrote the range).","commonSituations":"Misconfigured CDN or caching proxy that ignores or rewrites Range/Content-Range; mirrors that don't honour byte ranges; load balancers shuffling resume requests to a different backend with a different file.","solutions":["Retry the install; transient mid-stream mismatches often clear on a fresh download.","Disable resume retries for this mirror (--resume-retries 0) so pip restarts cleanly instead of resuming.","Switch to an index/mirror that honours HTTP Range requests correctly (e.g. PyPI directly).","Clear the pip cache (pip cache purge) in case a stale partial is being reused."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import IncompleteDownloadError\nfor _ in range(3):\n    try:\n        run_pip_install([\"pkg\"])\n        break\n    except IncompleteDownloadError:\n        continue","preventionTips":["Use mirrors/indexes that honour HTTP Range and Content-Range correctly.","Clear the pip cache if a partial seems to be reused.","Avoid mid-file resume against misbehaving CDNs; use --resume-retries 0 there."],"tags":["download","network","http-range","resume"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}