From 2aa7fc934a2bf294e2675cd4d524dc2b39e4d045 Mon Sep 17 00:00:00 2001 From: IdoPort Date: Mon, 14 Sep 2026 11:22:05 +0300 Subject: [PATCH] fix(ci): resolve post-merge test isolation leak and stale generated schema - test_custom_pass_through_endpoint_prefix_wins_over_native_provider_routes registered routes directly on the shared litellm.proxy.proxy_server.app singleton with no teardown, leaking /claude-aws/v1/files and /claude-aws/v1/batches into app.router.routes for the rest of the test session. A newer upstream test, test_gateway_plus_backend_covers_full_app, then flags those as routes uncovered by either component's allowlist. Snapshot app.router.routes before the test and restore it in a finally block. - Regenerate ui/litellm-dashboard/src/lib/http/schema.d.ts (npm run gen:api) against the post-merge backend; the prior merge left it stale by two lines (a soft_budget docstring entry removed upstream). --- .../test_llm_pass_through_endpoints.py | 47 +++++++++++-------- ui/litellm-dashboard/src/lib/http/schema.d.ts | 2 - 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py b/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py index 879c776a5bd..a451fad244a 100644 --- a/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py +++ b/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py @@ -3413,28 +3413,35 @@ def test_custom_pass_through_endpoint_prefix_wins_over_native_provider_routes(): ) from litellm.proxy.proxy_server import app - for suffix in ("files", "batches"): - InitPassThroughEndpointHelpers.add_exact_path_route( - app=app, - path=f"/claude-aws/v1/{suffix}", - target=f"https://example.com/v1/{suffix}", - custom_headers=None, - forward_headers=False, - merge_query_params=False, - dependencies=None, - cost_per_request=None, - endpoint_id=f"test-claude-aws-{suffix}", - ) + # app is the real, process-wide proxy app -- registering routes on it leaks + # into every other test (e.g. test_component_allowlists.py's full-route-coverage + # check) unless restored, so snapshot and restore app.router.routes afterward. + original_routes = list(app.router.routes) + try: + for suffix in ("files", "batches"): + InitPassThroughEndpointHelpers.add_exact_path_route( + app=app, + path=f"/claude-aws/v1/{suffix}", + target=f"https://example.com/v1/{suffix}", + custom_headers=None, + forward_headers=False, + merge_query_params=False, + dependencies=None, + cost_per_request=None, + endpoint_id=f"test-claude-aws-{suffix}", + ) - assert _resolve_route_name("POST", "/claude-aws/v1/files") == "endpoint_func" - assert _resolve_route_name("POST", "/claude-aws/v1/batches") == "endpoint_func" + assert _resolve_route_name("POST", "/claude-aws/v1/files") == "endpoint_func" + assert _resolve_route_name("POST", "/claude-aws/v1/batches") == "endpoint_func" - # registering a custom prefix must not disturb resolution of unrelated, - # already-registered native-provider routes - assert _resolve_route_name("POST", "/openai/v1/files") == "create_file" - assert _resolve_route_name("GET", "/azure/v1/files") == "list_files" - assert _resolve_route_name("POST", "/v1/files") == "create_file" - assert _resolve_route_name("POST", "/v1/batches") == "create_batch" + # registering a custom prefix must not disturb resolution of unrelated, + # already-registered native-provider routes + assert _resolve_route_name("POST", "/openai/v1/files") == "create_file" + assert _resolve_route_name("GET", "/azure/v1/files") == "list_files" + assert _resolve_route_name("POST", "/v1/files") == "create_file" + assert _resolve_route_name("POST", "/v1/batches") == "create_batch" + finally: + app.router.routes = original_routes def test_move_before_generic_provider_routes_is_a_no_op_without_a_generic_route(): diff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.ts index 7eadaa6c991..839aa52fa84 100644 --- a/ui/litellm-dashboard/src/lib/http/schema.d.ts +++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts @@ -16781,7 +16781,6 @@ export interface paths { * - permissions: Optional[dict] - [Not Implemented Yet] User-specific permissions, eg. turning off pii masking. * - metadata: Optional[dict] - Metadata for user, store information for user. Example metadata = {"team": "core-infra", "app": "app2", "email": "ishaan@berri.ai" } * - max_parallel_requests: Optional[int] - Rate limit a user based on the number of parallel requests. Raises 429 error, if user's parallel requests > x. - * - soft_budget: Optional[float] - Get alerts when user crosses given budget, doesn't block requests. * - model_max_budget: Optional[dict] - Model-specific max budget for user. [Docs](https://docs.litellm.ai/docs/proxy/users#add-model-specific-budgets-to-keys) * - budget_fallbacks: Optional[Dict[str, List[str]]] - Per-model fallback chain tried in order when that model's own `model_max_budget` is exceeded, e.g. {"gpt-4o": ["gpt-4o-mini"]}. * - model_rpm_limit: Optional[float] - Model-specific rpm limit for user. [Docs](https://docs.litellm.ai/docs/proxy/users#add-model-specific-limits-to-keys) @@ -16887,7 +16886,6 @@ export interface paths { * - permissions: Optional[dict] - [Not Implemented Yet] User-specific permissions, eg. turning off pii masking. * - metadata: Optional[dict] - Metadata for user, store information for user. Example metadata = {"team": "core-infra", "app": "app2", "email": "ishaan@berri.ai" } * - max_parallel_requests: Optional[int] - Rate limit a user based on the number of parallel requests. Raises 429 error, if user's parallel requests > x. - * - soft_budget: Optional[float] - Get alerts when user crosses given budget, doesn't block requests. * - model_max_budget: Optional[dict] - Model-specific max budget for user. [Docs](https://docs.litellm.ai/docs/proxy/users#add-model-specific-budgets-to-keys) * - budget_fallbacks: Optional[Dict[str, List[str]]] - Per-model fallback chain tried in order when that model's own `model_max_budget` is exceeded, e.g. {"gpt-4o": ["gpt-4o-mini"]}. * - model_rpm_limit: Optional[float] - Model-specific rpm limit for user. [Docs](https://docs.litellm.ai/docs/proxy/users#add-model-specific-limits-to-keys)