From e96ea1bead3fd778861c006ae052090e7d2ed756 Mon Sep 17 00:00:00 2001 From: Milan Date: Thu, 23 Apr 2026 13:02:04 +0300 Subject: [PATCH] refactor(auth): drop dead fallback in scope space-split branch The elif guard already requires `" " in claim_value.strip()`, which guarantees at least two non-empty tokens survive the split+filter, so `len(split_values) > 1` is always true. Collapses the ternary into a single comprehension (per Greptile review). Made-with: Cursor --- litellm/proxy/auth/user_api_key_auth.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/auth/user_api_key_auth.py b/litellm/proxy/auth/user_api_key_auth.py index 932bc90fe46..aa34eda62bf 100644 --- a/litellm/proxy/auth/user_api_key_auth.py +++ b/litellm/proxy/auth/user_api_key_auth.py @@ -168,9 +168,9 @@ def _routing_selector_matches_claim( ): # OAuth/OIDC often sends scope as a single space-delimited string. Only split # for the scope selector: iss/aud/client_id must stay exact full-string match - # on unverified claims (see routing override security review). - split_values = [v for v in claim_value.strip().split(" ") if v] - claim_list = split_values if len(split_values) > 1 else [claim_value] + # on unverified claims (see routing override security review). The elif guard + # (`" " in claim_value.strip()`) ensures at least two non-empty tokens survive. + claim_list = [v for v in claim_value.strip().split(" ") if v] else: claim_list = [str(claim_value)]