From 6f2b7bd887f7bdda2b2f005d29ec49e31d8c1164 Mon Sep 17 00:00:00 2001 From: IdoPort Date: Sun, 23 Aug 2026 13:16:04 +0300 Subject: [PATCH] test(proxy): cover the no-generic-route fallback in _move_before_generic_provider_routes Addresses Codecov patch-coverage gap on #38017: the documented safe no-op when no "/{provider}/..." route exists (e.g. a minimal deployment) was previously untested, since the real production app always has one registered. --- .../test_llm_pass_through_endpoints.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) 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 761f0218fce..113f2061ca9 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 @@ -3104,6 +3104,37 @@ def test_custom_pass_through_endpoint_prefix_wins_over_native_provider_routes(): assert _resolve_route_name("POST", "/v1/batches") == "create_batch" +def test_move_before_generic_provider_routes_is_a_no_op_without_a_generic_route(): + """ + If no generic "/{provider}/..." route is registered on the app (e.g. a minimal + deployment without the files/batches routers mounted), the newly-appended custom + route is left exactly where it was appended -- a safe no-op fallback. + """ + from litellm.proxy.pass_through_endpoints.pass_through_endpoints import ( + SafeRouteAdder, + ) + + class _FakeRoute: + def __init__(self, path): + self.path = path + + class _FakeRouter: + def __init__(self, routes): + self.routes = routes + + class _FakeApp: + def __init__(self, routes): + self.routes = routes + self.router = _FakeRouter(routes) + + routes = [_FakeRoute("/health"), _FakeRoute("/claude-aws/v1/files")] + app = _FakeApp(routes) + + SafeRouteAdder._move_before_generic_provider_routes(app=app) + + assert app.router.routes == routes + + class TestCursorProxyRoute: """Tests for the Cursor Cloud Agents pass-through route."""