Skip to content
Open
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 amber/src/main/python/core/models/type/large_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ def __init__(self, uri: Optional[str] = None):

if not uri.startswith("s3://"):
raise ValueError(f"largebinary URI must start with 's3://', got: {uri}")
parsed_uri = urlparse(uri)
if not parsed_uri.netloc or not parsed_uri.path.lstrip("/"):
raise ValueError("largebinary URI must include a bucket and object key")

self._uri = uri

Expand Down
4 changes: 4 additions & 0 deletions amber/src/test/python/core/models/type/test_large_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def test_invalid_uri_raises_value_error(self):
with pytest.raises(ValueError, match="largebinary URI must start with 's3://'"):
largebinary("invalid-uri")

for uri in ("s3://", "s3:///object", "s3://bucket", "s3://bucket/"):
with pytest.raises(ValueError, match="bucket and object key"):
largebinary(uri)

def test_get_bucket_name(self):
"""Test extracting bucket name from URI."""
large_binary = largebinary("s3://my-bucket/path/to/object")
Expand Down
Loading