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)
This commit is contained in:
Krrish Dholakia 2025-10-07 17:58:15 -07:00
parent 6c4436215c
commit b4fc7d3cfa

View file

@ -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,