python-poetry/poetry · error · PoetryError

Failed HTTP request: {method.upper()} {url}

Error message

Failed HTTP request: {method.upper()} {url}

What it means

A defensive PoetryError raised at the end of Authenticator.request if the request loop exits without returning a response or having raised (authenticator.py:279-280). The inline comment states 'this should never really be hit under any sane circumstance', so encountering it indicates either an unexpected code path, a logic gap in the retry/status handling, or an exotic retry-config edge case rather than a normal network failure.

Source

Thrown at src/poetry/utils/authenticator.py:280

                            debug=True,
                        )
                    )
                    raise exc
            else:
                if resp.status_code not in STATUS_FORCELIST or is_last_attempt:
                    if raise_for_status:
                        resp.raise_for_status()
                    return resp

            if not is_last_attempt:
                attempt += 1
                delay = self._get_backoff(resp, attempt)
                logger.debug("Retrying HTTP request in %s seconds.", delay)
                time.sleep(delay)
                continue

        # this should never really be hit under any sane circumstance
        raise PoetryError(f"Failed HTTP request: {method.upper()} {url}")

    def _get_backoff(self, response: requests.Response | None, attempt: int) -> float:
        if response is not None:
            retry_after = response.headers.get(RETRY_AFTER_HEADER, "")
            if retry_after:
                return float(retry_after)

        return 0.5 * attempt

    def get(self, url: str, **kwargs: Any) -> requests.Response:
        return self.request("get", url, **kwargs)

    def head(self, url: str, **kwargs: Any) -> requests.Response:
        kwargs.setdefault("allow_redirects", False)
        return self.request("head", url, **kwargs)

    def post(self, url: str, **kwargs: Any) -> requests.Response:
        return self.request("post", url, **kwargs)

View on GitHub (pinned to 92b74dcfe3)

Solutions

  1. Retry the originating command once — if it persists, it is likely a bug.
  2. Check for any custom Authenticator subclass or monkey-patching of STATUS_FORCELIST/retry params.
  3. Report the issue upstream with the method, URL, and Poetry version, since this path is meant to be unreachable.
  4. Work around by configuring credentials/URLs so the normal response path is taken.
Defensive patterns

Strategy: retry

Try / catch

from poetry.exceptions import PoetryError
for attempt in range(3):
    try:
        resp = authenticator.request(method, url)
        break
    except PoetryError as e:
        if "Failed HTTP request" in str(e) and attempt < 2:
            time.sleep(2 ** attempt)
            continue
        raise

Prevention

When it happens

Trigger: Authenticator.request(...) terminates its loop without hitting a return or raise — theoretically unreachable given the retry logic; could surface with unusual STATUS_FORCELIST/retry configuration or a code regression.

Common situations: Essentially never in normal use; if seen, suspect a bug in Poetry or a heavily customized authenticator/retry setup.

Related errors


AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04). Data as JSON: /data/errors/03ab8574238f2536.json. Report an issue: GitHub.