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>
This commit is contained in:
apex-mochen 2026-10-10 13:59:25 +00:00
parent d78aec0878
commit 9937e2cc13

View file

@ -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(