Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d646442
Stream hf:// files from the CDN to avoid Hub rate limits (#664)
tristan-deep Oct 26, 2026
62e40e6
Validate ZEA_MAX_CONCURRENT_REQUESTS and keep the retry log off the e…
tristan-deep Oct 26, 2026
bde3508
Redact signed URLs in fsspec's HTTP debug log
tristan-deep Oct 26, 2026
1f4122d
fixed potential burst of requests on ttl expiry
Louisvh Oct 29, 2026
4bb3aee
Merge branch 'main' into feature/hf-cdn-streaming
tristan-deep Nov 2, 2026
d3b0c59
improve fetching of small chunks
tristan-deep Nov 2, 2026
e465a91
Keep large chunks on the merged path and make read_at thread-safe
tristan-deep Nov 2, 2026
d378820
Merge remote-tracking branch 'origin/main' into feature/hf-cdn-streaming
tristan-deep Nov 4, 2026
cd2bcb6
Drop cached CDN URLs on upload and reuse branch URLs only as long as …
tristan-deep Nov 4, 2026
206600e
Ask the Hub at most once per cooldown when a URL refresh gives nothin…
tristan-deep Nov 4, 2026
9e9954e
Keep using the current URL when its early refresh fails
tristan-deep Nov 4, 2026
a138178
Redact signed URLs in the errors of failed range requests
tristan-deep Nov 4, 2026
0a2ba87
Draw no progress bar for reads below MIN_BYTES
tristan-deep Nov 4, 2026
68c62c7
Check the chunk cache with a stat in pending_bytes
tristan-deep Nov 4, 2026
7b3d0ec
Fetch the blocks of a small read concurrently
tristan-deep Nov 4, 2026
3f43635
Merge ranges only while a request downloads no more gap bytes than ch…
tristan-deep Nov 4, 2026
afcc0ef
Keep one block cache per streamed file instead of two
tristan-deep Nov 4, 2026
dca16d0
Ask the stream whether it keeps the blocks it reads
tristan-deep Nov 4, 2026
dcd792d
Share the on-disk cache helpers of the Hub listing and the CDN URLs
tristan-deep Nov 4, 2026
3fcd16b
Merge branch 'main' into feature/hf-cdn-streaming
tristan-deep Nov 4, 2026
08f275f
Merge branch 'main' into feature/hf-cdn-streaming
swpenninga Nov 4, 2026
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
Prev Previous commit
Next Next commit
Redact signed URLs in the errors of failed range requests
fsspec and aiohttp put the requested URL in FileNotFoundError and ClientResponseError, so
a request that kept failing showed a working signed CDN URL in tracebacks and logs. Such
errors are re-raised with the query string redacted (FileNotFoundError and PermissionError
keep their type, others become RemoteReadError with the status). The redaction pattern
now also stops at quotes.
  • Loading branch information
tristan-deep committed Nov 4, 2026
commit a1381780471cfb41d2d974b1ad69c9baaa0225c6
22 changes: 22 additions & 0 deletions tests/data/test_chunk_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,28 @@ def test_fsspec_debug_log_redacts_signed_urls(structured_file, caplog):
server.close()


@pytest.mark.parametrize(
"name, status, error",
[("gone.hdf5", None, FileNotFoundError), (None, 403, chunk_reader.RemoteReadError)],
)
def test_errors_redact_signed_urls(structured_file, name, status, error):
"""The error of a failed request names the file, but not the signature of its URL."""
server = _CountingServer(
structured_file.parent, latency=0, reject_first=100 if status else 0, reject_status=status
)
try:
name = name or structured_file.name
fetcher = HTTPFetcher(server.url + name + "?Policy=abc&Signature=secret")
with pytest.raises(error) as info:
fetcher.fetch([(0, 16)])
assert name in str(info.value) and "secret" not in str(info.value)
assert info.value.__suppress_context__
if status == 403:
assert info.value.status == 403
finally:
server.close()


class TestIsTransient:
@pytest.mark.parametrize("status", sorted(chunk_reader.RETRY_STATUS))
def test_transient_statuses(self, status):
Expand Down
31 changes: 29 additions & 2 deletions zea/data/chunk_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def refresh(self, stale_url: str) -> bool: ...
class _RedactQueryStrings(logging.Filter):
"""Strip query strings from URLs in log records: they carry the signature of a CDN URL."""

_url = re.compile(r"(https?://[^\s?]+)\?\S*")
_url = re.compile(r"(https?://[^\s?'\"]+)\?[^\s'\"]*")

def filter(self, record: logging.LogRecord) -> bool:
message = record.getMessage()
Expand All @@ -201,6 +201,30 @@ def filter(self, record: logging.LogRecord) -> bool:
return True


class RemoteReadError(OSError):
"""A failed range request whose message had a signed URL in it (now redacted)."""

def __init__(self, message: str, status: int | None = None):
super().__init__(message)
self.status = status


def _redacted(exc: Exception) -> Exception | None:
"""``exc`` with the query strings of its URLs redacted, or ``None`` if it has none.

fsspec and aiohttp put the requested URL in their errors, and a signed URL is a credential.
"""
message = str(exc)
redacted = _RedactQueryStrings._url.sub(r"\1?<redacted>", message)
if redacted == message:
return None
if isinstance(exc, FileNotFoundError):
return FileNotFoundError(redacted)
if isinstance(exc, PermissionError):
return PermissionError(redacted)
return RemoteReadError(redacted, getattr(exc, "status", None))


_redaction_lock = threading.Lock()


Expand Down Expand Up @@ -437,7 +461,10 @@ async def _cat_range(self, offset: int, size: int, url: str, headers: dict) -> b
url, headers = await asyncio.to_thread(self.location.current)
continue
if not _is_transient(exc) or attempt >= MAX_RETRIES:
raise
redacted = _redacted(exc)
if redacted is None:
raise
raise redacted from None
from zea import log # local, like the fallback warning below: zea imports us

status = getattr(exc, "status", None)
Expand Down