mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
fix(proxy): scope wildcard cleanup to subpath entries and restore registry in test
- Only remove wildcard path from openai_routes when the route entry has type="subpath", avoiding accidental removal when two endpoints share the same base path but differ in include_subpath - Clean up _registered_pass_through_routes in the test finally block to prevent stale entries from polluting subsequent tests on failure
This commit is contained in:
parent
97b7358791
commit
ab1744f9fe
2 changed files with 11 additions and 4 deletions
|
|
@ -2033,13 +2033,13 @@ class InitPassThroughEndpointHelpers:
|
|||
route_info = _registered_pass_through_routes[key]
|
||||
path = route_info.get("path")
|
||||
if isinstance(path, str):
|
||||
# Remove base path and wildcard path from openai_routes
|
||||
openai_routes = LiteLLMRoutes.openai_routes.value
|
||||
if path in openai_routes:
|
||||
openai_routes.remove(path)
|
||||
wildcard_path = path.rstrip("/") + "/*"
|
||||
if wildcard_path in openai_routes:
|
||||
openai_routes.remove(wildcard_path)
|
||||
if route_info.get("type") == "subpath":
|
||||
wildcard_path = path.rstrip("/") + "/*"
|
||||
if wildcard_path in openai_routes:
|
||||
openai_routes.remove(wildcard_path)
|
||||
del _registered_pass_through_routes[key]
|
||||
verbose_proxy_logger.debug(
|
||||
"Removed pass-through route from registry: %s", key
|
||||
|
|
|
|||
|
|
@ -1397,3 +1397,10 @@ async def test_initialize_pass_through_registers_wildcard_for_auth_subpath():
|
|||
assert wildcard_path not in LiteLLMRoutes.openai_routes.value
|
||||
finally:
|
||||
LiteLLMRoutes.openai_routes.value[:] = original_routes
|
||||
# Clean up any routes registered during this test to avoid
|
||||
# polluting the module-level _registered_pass_through_routes
|
||||
registered = InitPassThroughEndpointHelpers.get_all_registered_pass_through_routes()
|
||||
for k in registered:
|
||||
InitPassThroughEndpointHelpers.remove_endpoint_routes(
|
||||
k.split(":")[0]
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue