Skip to content
Merged
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
3 changes: 3 additions & 0 deletions src/hflow/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,9 @@ def fetch_uri(uri: "str | Path") -> Path:
one-off ``app.process("gs://...")`` sources.
"""
if isinstance(uri, str) and is_bucket_url(uri):
_scheme, _sep, remainder = uri.partition("://")
if "/" not in remainder or not remainder.partition("/")[2].strip("/"):
raise ValueError(f"bucket URI {uri!r} names no object")
parent_url, _, name = uri.rpartition("/")
if not name:
raise ValueError(f"bucket URI {uri!r} names no object")
Expand Down
14 changes: 14 additions & 0 deletions tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import errno
import os
import re
import sys
from pathlib import Path

Expand Down Expand Up @@ -403,6 +404,19 @@ def test_default_mirror_is_stable_per_url(
assert first.mirror != other.mirror
assert first.mirror.is_relative_to(tmp_path / "mirrors")

def test_bucket_uri_naming_no_object_is_refused(self) -> None:
refused = [
"gs://bucket/",
"s3://bucket/prefix/",
"gs://bucket//",
"gs://bucket",
"s3://bucket",
]
for uri in refused:
pattern = rf"^bucket URI {re.escape(repr(uri))} names no object$"
with pytest.raises(ValueError, match=pattern):
fetch_uri(uri)


class TestBucketPipeline:
def test_process_publishes_episode_marker_and_catalog(
Expand Down