From b6320a9d678aef67022dedce887e076539276943 Mon Sep 17 00:00:00 2001 From: Jeeho Lee Date: Tue, 13 Oct 2026 09:19:52 +0000 Subject: [PATCH] fix(artifacts): classify MIME types without case sensitivity Assisted-by: OpenAI Codex --- src/google/adk/tools/load_artifacts_tool.py | 2 +- tests/unittests/tools/test_load_artifacts_tool.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/google/adk/tools/load_artifacts_tool.py b/src/google/adk/tools/load_artifacts_tool.py index b6e727cfa4..d04c3deee8 100644 --- a/src/google/adk/tools/load_artifacts_tool.py +++ b/src/google/adk/tools/load_artifacts_tool.py @@ -85,7 +85,7 @@ def _normalize_mime_type(mime_type: str | None) -> str | None: """Returns the normalized MIME type, without parameters like charset.""" if not mime_type: return None - return mime_type.split(';', 1)[0].strip() + return mime_type.split(';', 1)[0].strip().lower() def _is_inline_mime_type_supported(mime_type: str | None) -> bool: diff --git a/tests/unittests/tools/test_load_artifacts_tool.py b/tests/unittests/tools/test_load_artifacts_tool.py index 35b68f9dad..216acb30fb 100644 --- a/tests/unittests/tools/test_load_artifacts_tool.py +++ b/tests/unittests/tools/test_load_artifacts_tool.py @@ -429,7 +429,14 @@ async def test_load_artifacts_keeps_supported_mime_types(): @pytest.mark.asyncio @pytest.mark.parametrize( 'mime_type', - ['image/svg+xml', 'image/svg', 'application/svg+xml', 'image/xml'], + [ + 'image/svg+xml', + 'image/svg', + 'application/svg+xml', + 'image/xml', + 'Image/SVG+XML; charset=UTF-8', + 'APPLICATION/SVG+XML', + ], ) async def test_load_artifacts_converts_svg_to_text(mime_type): """SVG/XML image variants are rejected by Gemini with 400 INVALID_ARGUMENT,