From 9937e2cc13bb0bdfa19517d19efcfde6cd58a315 Mon Sep 17 00:00:00 2001 From: apex-mochen <2756823972@qq.com> Date: Sat, 10 Oct 2026 13:59:25 +0000 Subject: [PATCH] fix(proxy): strip the query string before matching vertex methods `_matches_vertex_method` matched on the full url_route, so a canonical route with a query string (e.g. ``.../gemini-3.8-flash:streamGenerateContent?alt=sse``) no longer matched after the substring-hardening of #45787. Mid-stream vertex interruptions then failed to bill the already-delivered usage (test_chunk_processor_bills_partial_google_usage_on_mid_stream_exception). Match on the URL path (urlparse(...).path) instead; bare trailing-path forms still match, and plain substring hits stay rejected. Signed-off-by: apex-mochen <2756823972@qq.com> --- .../vertex_passthrough_logging_handler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/vertex_passthrough_logging_handler.py b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/vertex_passthrough_logging_handler.py index 5372c7a72cf..78843749b36 100644 --- a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/vertex_passthrough_logging_handler.py +++ b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/vertex_passthrough_logging_handler.py @@ -129,8 +129,12 @@ class VertexPassthroughLoggingHandler: ``.../models/gemini-2.0-flash:predict``) and its bare trailing path-segment form (e.g. ``/v1/generateContent``), while rejecting plain substring hits such as ``http://example.com/api/predict/laya`` that caused #45787. + + The query string is stripped first so a route such as + ``.../gemini-3.8-flash:streamGenerateContent?alt=sse`` still matches. """ - return url_route.endswith(method) or url_route.endswith(":" + method) + path = urlparse(url_route).path + return path.endswith(method) or path.endswith(":" + method) @staticmethod def vertex_passthrough_handler(