From b4fc7d3cfad04e40e257be8ceb193bf6074f636e Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 7 Oct 2025 17:58:15 -0700 Subject: [PATCH] feat(pass_through_endpoints.py): raise 404 if passthrough endpoint has been deleted by the user Ensures passthrough endpoint deletion works as expected (single-instance) --- .../pass_through_endpoints.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py index 5f3a49f307a..8542f87327f 100644 --- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py +++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py @@ -974,6 +974,11 @@ def create_pass_through_route( ] = None, # if pass-through endpoint is a streaming request subpath: str = "", # captures sub-paths when include_subpath=True ): + + from litellm.proxy.pass_through_endpoints.pass_through_endpoints import ( + InitPassThroughEndpointHelpers, + ) + # Construct the full target URL with subpath if needed full_target = ( HttpPassThroughEndpointHelpers.construct_target_url_with_subpath( @@ -981,6 +986,14 @@ def create_pass_through_route( ) ) + if not InitPassThroughEndpointHelpers.is_registered_pass_through_route( + route=endpoint + ): + raise HTTPException( + status_code=404, + detail=f"Pass-through endpoint {target} not found. This could have been deleted or not yet added to the proxy.", + ) + return await pass_through_request( # type: ignore request=request, target=full_target,