From 22df51c04520927ebc8e437059e9653af52d48b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Mon, 26 Feb 2024 06:50:29 +0100 Subject: [PATCH] lazy-wheel: handle internal server error if the server returns an internal server error (500), it probably does not support negative offsets --- src/poetry/inspection/lazy_wheel.py | 9 +++++++-- tests/inspection/test_lazy_wheel.py | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/poetry/inspection/lazy_wheel.py b/src/poetry/inspection/lazy_wheel.py index 885ea7166e5..47b897bf5d5 100644 --- a/src/poetry/inspection/lazy_wheel.py +++ b/src/poetry/inspection/lazy_wheel.py @@ -611,13 +611,18 @@ def _extract_content_length( resp = e.response code = resp.status_code if resp is not None else None # Our initial request using a negative byte range was not supported. - if code in [codes.not_implemented, codes.method_not_allowed]: + if code in [ + codes.internal_server_error, + codes.not_implemented, + codes.method_not_allowed, + ]: # pypi notably does not support negative byte ranges: see # https://github.com/pypi/warehouse/issues/12823. logger.debug( "Negative byte range not supported for domain '%s': " - "using HEAD request before lazy wheel from now on", + "using HEAD request before lazy wheel from now on (code: %s)", domain, + code, ) # Avoid trying a negative byte range request against this domain for the # rest of the resolve. diff --git a/tests/inspection/test_lazy_wheel.py b/tests/inspection/test_lazy_wheel.py index b32bdd48d4f..7eea30f33de 100644 --- a/tests/inspection/test_lazy_wheel.py +++ b/tests/inspection/test_lazy_wheel.py @@ -158,6 +158,7 @@ def handle_request( None, (codes.method_not_allowed, b"Method not allowed"), (codes.requested_range_not_satisfiable, b"Requested range not satisfiable"), + (codes.internal_server_error, b"Internal server error"), (codes.not_implemented, b"Unsupported client range"), (NEGATIVE_OFFSET_AS_POSITIVE, b"handle negative offset as positive"), ],