From d5f3224309ea3196871c1f3b8ca024b1b713eca2 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 18 May 2026 15:24:37 +0000 Subject: [PATCH] fix(vertex_ai/gemini): strip MIME parameters from GCS contentType GCS object metadata's contentType field can include parameters such as 'text/html; charset=utf-8'. Strip them in _apply_gemini_mime_type_aliases so downstream get_file_extension_from_mime_type sees a bare MIME type. Co-authored-by: Yassin Kortam --- litellm/llms/vertex_ai/gemini/transformation.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/litellm/llms/vertex_ai/gemini/transformation.py b/litellm/llms/vertex_ai/gemini/transformation.py index f92e3ae4ca8..a109769f832 100644 --- a/litellm/llms/vertex_ai/gemini/transformation.py +++ b/litellm/llms/vertex_ai/gemini/transformation.py @@ -73,10 +73,13 @@ _GEMINI_MIME_TYPE_ALIASES: Dict[str, str] = { def _apply_gemini_mime_type_aliases(mime_type: str) -> str: - """Normalize known MIME aliases only; does not consult the file-type registry.""" - return _GEMINI_MIME_TYPE_ALIASES.get( - mime_type.strip().lower(), mime_type.strip().lower() - ) + """Normalize known MIME aliases only; does not consult the file-type registry. + + Also strips MIME parameters (e.g. ``; charset=utf-8``) so that values + sourced from GCS object metadata (``contentType``) validate correctly. + """ + normalized = mime_type.split(";", 1)[0].strip().lower() + return _GEMINI_MIME_TYPE_ALIASES.get(normalized, normalized) def _get_vertex_base() -> Any: