Skip to content

Commit 87cea32

Browse files
committed
Avoid supporing download item from s3
1 parent fb584c4 commit 87cea32

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pydantic_ai_slim/pydantic_ai/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,8 @@ async def download_item(
11721172
"""
11731173
if item.url.startswith('gs://'):
11741174
raise UserError('Downloading from protocol "gs://" is not supported.')
1175+
elif item.url.startswith('s3://'):
1176+
raise UserError('Downloading from protocol "s3://" is not supported.')
11751177
elif isinstance(item, VideoUrl) and item.is_youtube:
11761178
raise UserError('Downloading YouTube videos is not supported.')
11771179

tests/models/test_download_item.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ async def test_download_item_raises_user_error_with_gs_uri(
2424
_ = await download_item(url, data_format='bytes')
2525

2626

27+
@pytest.mark.parametrize(
28+
'url',
29+
(
30+
pytest.param(AudioUrl(url='s3://my-bucket/audio.wav')),
31+
pytest.param(DocumentUrl(url='s3://my-bucket/document.pdf')),
32+
pytest.param(ImageUrl(url='s3://my-bucket/image.png')),
33+
pytest.param(VideoUrl(url='s3://my-bucket/video.mp4')),
34+
),
35+
)
36+
async def test_download_item_raises_user_error_with_s3_uri(
37+
url: AudioUrl | DocumentUrl | ImageUrl | VideoUrl,
38+
) -> None:
39+
with pytest.raises(UserError, match='Downloading from protocol "s3://" is not supported.'):
40+
_ = await download_item(url, data_format='bytes')
41+
42+
2743
async def test_download_item_raises_user_error_with_youtube_url() -> None:
2844
with pytest.raises(UserError, match='Downloading YouTube videos is not supported.'):
2945
_ = await download_item(VideoUrl(url='https://youtu.be/lCdaVNyHtjU'), data_format='bytes')

0 commit comments

Comments
 (0)