Repository navigation
fix(multimodal): return 4xx for SSRF-blocked media URLs instead of 500 #11312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9d1ff3a
fix(multimodal): return 4xx for SSRF-blocked media URLs instead of 500
KrishnanPrash 305f709
fix(multimodal): drop internal ticket refs, lazy log format, add trtl…
KrishnanPrash 9b8bd1b
refactor(multimodal): trim comments to why-only, consolidate SSRF tests
KrishnanPrash 909a6cd
test(multimodal): add multimodal component marker to trtllm test
KrishnanPrash aa4a16c
Merge branch 'main' into kprashanth/dyn-3389
KrishnanPrash c89e0a7
test(multimodal): skip trtllm test at collection when CUDA is unavail…
KrishnanPrash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
components/src/dynamo/trtllm/tests/test_trtllm_multimodal_processor.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """process_openai_request must let client-error types from image loading | ||
| propagate (so the frontend returns a 4xx) instead of swallowing them to None.""" | ||
|
|
||
| from unittest.mock import AsyncMock, MagicMock | ||
|
|
||
| import pytest | ||
| import torch | ||
|
|
||
| # multimodal_processor imports tensorrt_llm, whose import needs CUDA. -m selection | ||
| # happens after collection, so this module is still imported on the CPU-only step; | ||
| # skip at collection there to avoid an ImportError. GPU runs it via the gpu_1 marker. | ||
| if not torch.cuda.is_available(): | ||
| pytest.skip( | ||
| "CUDA/GPU not available, but tensorrt_llm import and the test require GPU.", | ||
| allow_module_level=True, | ||
| ) | ||
|
|
||
| from dynamo.common.http import HttpStatusError | ||
| from dynamo.common.http.url_validator import UrlValidationError | ||
| from dynamo.trtllm.multimodal_processor import MultimodalRequestProcessor | ||
|
|
||
| pytestmark = [ | ||
| pytest.mark.unit, | ||
| pytest.mark.trtllm, | ||
| pytest.mark.multimodal, | ||
| pytest.mark.pre_merge, | ||
| pytest.mark.gpu_1, | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
|
||
| pytest.mark.profiled_vram_gib(0), | ||
| ] | ||
|
KrishnanPrash marked this conversation as resolved.
|
||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| @pytest.mark.parametrize( | ||
| "error", | ||
| [ | ||
| UrlValidationError("blocked IP literal"), | ||
| HttpStatusError(415, "Unsupported Media Type", "https://example.com/x.png"), | ||
| ], | ||
| ) | ||
| async def test_client_errors_propagate(error) -> None: | ||
| # Mock tokenizer skips tokenizer_factory; mock loader forces the failure. | ||
| processor = MultimodalRequestProcessor( | ||
| model_type="multimodal", | ||
| model_dir="unused", | ||
| max_file_size_mb=10, | ||
| tokenizer=MagicMock(), | ||
| ) | ||
| processor.image_loader.load_image_batch = AsyncMock(side_effect=error) | ||
|
|
||
| request = { | ||
| "multi_modal_data": {"image_url": [{"Url": "https://example.com/x.png"}]} | ||
| } | ||
| with pytest.raises(type(error)): | ||
| await processor.process_openai_request( | ||
| request, embeddings=None, ep_disaggregated_params=None | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.