From 489af0b8b11797c6728af298d6414e8084752121 Mon Sep 17 00:00:00 2001 From: moe-berri Date: Mon, 26 Oct 2026 21:11:02 -0700 Subject: [PATCH] fix(lens): limit changes to Lens integration --- backend/main.py | 1 - gateway/main.py | 1 - litellm/proxy/_lazy_features.py | 7 +------ tests/unit/proxy/test_component_allowlists.py | 10 ++-------- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/backend/main.py b/backend/main.py index b6ec6cb8c44..e0cef90c979 100644 --- a/backend/main.py +++ b/backend/main.py @@ -55,7 +55,6 @@ async def _backend_lifespan( app_: Starlette, lifespan: Lifespan[Starlette] = _proxy_lifespan ) -> AsyncGenerator[Mapping[str, object], None]: async with lifespan(app_) as state: - app_.state.component_route_filter = _is_backend_route app_.router.routes = [r for r in app_.router.routes if _is_backend_route(r)] yield state if state is not None else {} diff --git a/gateway/main.py b/gateway/main.py index 3476c08dc7c..fb4ae830808 100644 --- a/gateway/main.py +++ b/gateway/main.py @@ -66,7 +66,6 @@ async def _gateway_lifespan( app_: Starlette, lifespan: Lifespan[Starlette] = _proxy_lifespan ) -> AsyncGenerator[Mapping[str, object], None]: async with lifespan(app_) as state: - app_.state.component_route_filter = _is_gateway_route app_.router.routes = [r for r in app_.router.routes if _is_gateway_route(r)] yield state if state is not None else {} diff --git a/litellm/proxy/_lazy_features.py b/litellm/proxy/_lazy_features.py index f15ce81bd3e..4e54d6ac733 100644 --- a/litellm/proxy/_lazy_features.py +++ b/litellm/proxy/_lazy_features.py @@ -455,12 +455,7 @@ def _route_table( lazy_routes: Mapping[str, tuple[BaseRoute, ...]], features: tuple[LazyFeature, ...], ) -> list[BaseRoute]: # mutable-ok: assigned to Router.routes, a list - allowed: Final[Callable[[BaseRoute], bool] | None] = getattr(app.state, "component_route_filter", None) - ordered: Final = tuple( - route - for route in _in_registry_order(routes, lazy_routes, features, _lazy_slots(app)) - if allowed is None or allowed(route) - ) + ordered: Final = _in_registry_order(routes, lazy_routes, features, _lazy_slots(app)) if builtin_pass_through_routes_first(): return hot_routes_first(ordered) return hot_routes_first( diff --git a/tests/unit/proxy/test_component_allowlists.py b/tests/unit/proxy/test_component_allowlists.py index 2e38214d733..eb058d01770 100644 --- a/tests/unit/proxy/test_component_allowlists.py +++ b/tests/unit/proxy/test_component_allowlists.py @@ -162,7 +162,6 @@ def test_composed_lifespan_preserves_request_state_and_teardown( def register_trace_route(application: Starlette, module: object) -> None: application.router.routes.append(Route("/v1/traces", trace_state)) - application.router.routes.append(Route("/not-a-component-route/lazy", trace_state)) @asynccontextmanager async def stateful_lifespan(application: Starlette) -> AsyncGenerator[Mapping[str, object], None]: @@ -190,14 +189,9 @@ def test_composed_lifespan_preserves_request_state_and_teardown( assert response.json() == {"keys": [] if state_kind == "stateless" else sorted(state)} filtered: Final = client.get("/not-a-component-route") assert filtered.status_code == (200 if component_lifespan is None else 404), filtered.text - lazy_filtered: Final = client.get("/not-a-component-route/lazy") - assert lazy_filtered.status_code == (200 if component_lifespan is None else 404), lazy_filtered.text - assert events == ( - ["startup", "request", "request", "request"] if component_lifespan is None else ["startup", "request"] - ) + assert events == (["startup", "request", "request"] if component_lifespan is None else ["startup", "request"]) assert events == ( - ["startup", "request", "request", "request", "shutdown"] - if component_lifespan is None else ["startup", "request", "shutdown"] + ["startup", "request", "request", "shutdown"] if component_lifespan is None else ["startup", "request", "shutdown"] )