Reject oversized media before fully downloading it (#51896)
Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com> Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com>
This commit is contained in:
co-authored by
Lucas Bourtoule
parent
585bb07c70
commit
2ec6f0d71e
@@ -13,6 +13,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
||||
import aiohttp
|
||||
import pytest
|
||||
|
||||
from vllm.connections import MediaDownloadSizeExceededError
|
||||
from vllm.entrypoints.serve import create_error_response
|
||||
from vllm.exceptions import VLLMClientError, VLLMUnprocessableEntityError
|
||||
from vllm.multimodal.media import MediaConnector
|
||||
@@ -134,6 +135,19 @@ class TestMediaConnectorErrorHandling:
|
||||
|
||||
assert isinstance(exc_info.value, aiohttp.ClientConnectionError)
|
||||
|
||||
def test_fetch_image_download_size_limit_error(self):
|
||||
connector = MediaConnector()
|
||||
|
||||
with patch.object(
|
||||
connector.connection, "get_bytes", new_callable=MagicMock
|
||||
) as mock_get:
|
||||
mock_get.side_effect = MediaDownloadSizeExceededError(256 * 1024 * 1024)
|
||||
|
||||
with pytest.raises(VLLMUnprocessableEntityError) as exc_info:
|
||||
connector.fetch_image("https://example.com/image.jpg")
|
||||
|
||||
assert "VLLM_MAX_MEDIA_DOWNLOAD_SIZE_MB=256" in str(exc_info.value)
|
||||
|
||||
|
||||
class TestErrorResponse:
|
||||
"""Tests for error response creation."""
|
||||
|
||||
Reference in New Issue
Block a user