Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions scripts/ci/materialize_base_python_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import sys
import tarfile
import tempfile
import urllib.error
import urllib.parse
import urllib.request
from typing import Any
Expand Down Expand Up @@ -65,8 +66,14 @@ def redirect_request(
new_url: str,
) -> None:
"""Fail closed for all redirect status codes and target locations."""
del request, response, code, message, headers, new_url
raise RuntimeError("trusted uv archive redirects are forbidden")
del message, new_url
raise urllib.error.HTTPError(
request.full_url, # type: ignore
code,
"trusted uv archive redirects are forbidden",
headers,
response,
)


@functools.cache
Expand Down
3 changes: 2 additions & 1 deletion tests/test_uv_redirect_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import urllib.error
import urllib.request
from collections.abc import Iterator

Expand All @@ -23,7 +24,7 @@ def test_trusted_uv_redirect_handler_rejects_before_following() -> None:
handler = materializer._RejectTrustedUvRedirects()
original = urllib.request.Request(materializer.TRUSTED_UV_ARCHIVE_URL)

with pytest.raises(RuntimeError, match="redirects are forbidden"):
with pytest.raises(urllib.error.HTTPError, match="trusted uv archive redirects are forbidden"):
handler.redirect_request(
original,
None,
Expand Down
Loading