{"id":"5338d7b787a44104","repo":"python-poetry/poetry","slug":"e","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"http","errorClass":"RepositoryError","httpStatus":null,"severity":"error","filePath":"src/poetry/repositories/http_repository.py","lineNumber":554,"sourceCode":"    def _get_response(\n        self, endpoint: str, *, headers: dict[str, str] | None = None\n    ) -> requests.Response | None:\n        url = self._url + endpoint\n        try:\n            response: requests.Response = self.session.get(\n                url, raise_for_status=False, timeout=REQUESTS_TIMEOUT, headers=headers\n            )\n            if response.status_code in (401, 403):\n                self._log(\n                    f\"Authorization error accessing {url}\",\n                    level=\"warning\",\n                )\n                return None\n            if response.status_code == 404:\n                return None\n            response.raise_for_status()\n        except requests.exceptions.HTTPError as e:\n            raise RepositoryError(e)\n\n        if response.url != url:\n            self._log(\n                f\"Response URL {response.url} differs from request URL {url}\",\n                level=\"debug\",\n            )\n        return response\n\n    def _get_prefer_json_header(self) -> dict[str, str]:\n        # Prefer json, but accept anything for backwards compatibility.\n        # Although the more specific value should be preferred to the less specific one\n        # according to https://developer.mozilla.org/en-US/docs/Glossary/Quality_values,\n        # we add a quality value because some servers still prefer html without one.\n        return {\"Accept\": \"application/vnd.pypi.simple.v1+json, */*;q=0.1\"}\n\n    def _is_json_response(self, response: requests.Response) -> bool:\n        return (\n            response.headers.get(\"Content-Type\", \"\").split(\";\")[0].strip()","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/repositories/http_repository.py#L536-L572","documentation":"RepositoryError wraps a requests.exceptions.HTTPError raised while fetching a repository page in HTTPRepository._get_response (http_repository.py:553-554). It is raised after the request exits the retry loop with a non-retryable (or final-attempt) HTTP error from raise_for_status(). This is the generic transport/status failure for repository HTTP calls.","triggerScenarios":"Any repository page fetch returning a 5xx (after STATUS_FORCELIST retries are exhausted) or another status that requests treats as HTTPError; also raised when raise_for_status() trips inside the response handling.","commonSituations":"Index/mirror server down or returning 500/502/503; a corporate proxy returning an unexpected status; a malformed repository URL returning an HTML error page with a success-ish code path.","solutions":["Check that the repository URL in [[tool.poetry.source]] is correct and reachable (curl -I the simple index).","Retry later if the server is returning transient 5xx errors.","If behind a proxy, verify HTTP_PROXY/HTTPS_PROXY and corporate proxy behavior.","Inspect the wrapped exception (str(e) is the original HTTPError) for the exact status code."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Smoke-check reachability before heavy resolution\nimport requests\ntry:\n    requests.head(repository_url, timeout=10).raise_for_status()\nexcept requests.RequestException as e:\n    raise RuntimeError(f\"repository unreachable: {e}\") from e","typeGuard":null,"tryCatchPattern":"from poetry.repositories.exceptions import RepositoryError\nattempts = 0\nwhile True:\n    try:\n        page = repository._get_page(name)\n        break\n    except RepositoryError as e:\n        attempts += 1\n        if attempts >= 3:\n            raise\n        time.sleep(2 ** attempts)","preventionTips":["Monitor repository/mirror uptime and fail over to a mirror.","Set realistic network timeouts and retry budgets in CI.","Keep proxy configuration (HTTP_PROXY/HTTPS_PROXY) correct for the environment."],"tags":["network","http","repository","status-code"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}