From 17b5b90526836a5bec95e82e6874445992b9a235 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Fri, 6 Mar 2026 16:02:27 -0800 Subject: [PATCH] remove dead-code response=None guard in _pkce_token_exchange --- litellm/proxy/management_endpoints/ui_sso.py | 21 ++++---------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/litellm/proxy/management_endpoints/ui_sso.py b/litellm/proxy/management_endpoints/ui_sso.py index fe5d3f1e9a7..02b81dedd5c 100644 --- a/litellm/proxy/management_endpoints/ui_sso.py +++ b/litellm/proxy/management_endpoints/ui_sso.py @@ -2794,14 +2794,10 @@ class SSOAuthenticationHandler: if client_secret: token_data["client_secret"] = client_secret - # Initialize response to None — guards against an UnboundLocalError in the - # unlikely case where httpx.AsyncClient() construction itself raises before - # the POST is attempted. The try/except is INSIDE the async with so that - # TLS teardown exceptions from __aexit__ propagate as-is and are NOT - # mis-labelled as "Token endpoint request failed". httpx buffers the full - # response body before __aexit__, so status_code / text / json() remain - # valid after the context exits. - response = None + # The try/except is INSIDE the async with so that TLS teardown exceptions + # from __aexit__ propagate as-is and are NOT mis-labelled as "Token endpoint + # request failed". httpx buffers the full response body before __aexit__, + # so status_code / text / json() remain valid after the context exits. async with httpx.AsyncClient() as http_client: try: response = await http_client.post(token_endpoint, **post_kwargs) @@ -2817,15 +2813,6 @@ class SSOAuthenticationHandler: code=status.HTTP_401_UNAUTHORIZED, ) from exc - if response is None: - # Should never happen in practice — construction failure is unexpected. - raise ProxyException( - message="Token endpoint request did not return a response", - type=ProxyErrorTypes.auth_error, - param="token_exchange", - code=status.HTTP_401_UNAUTHORIZED, - ) - # Response processing outside the async with — httpx buffers the full # response body so status_code / text / json() remain valid after __aexit__. if response.status_code != 200: