From 10054617b54d09613701f60b976d8f3ce4880313 Mon Sep 17 00:00:00 2001 From: Vasilisa Parshikova Date: Thu, 5 Mar 2026 15:42:20 +0400 Subject: [PATCH] (sap) fix after bot review --- litellm/llms/sap/credentials.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/litellm/llms/sap/credentials.py b/litellm/llms/sap/credentials.py index 97d77c4ff19..be272ff11c4 100644 --- a/litellm/llms/sap/credentials.py +++ b/litellm/llms/sap/credentials.py @@ -33,9 +33,18 @@ def _get_home() -> str: def _get_nested(d: Union[Dict[str, Any], str], path: Sequence[str]) -> Any: cur: Any = d if isinstance(cur, str): - cur = json.loads(cur) + try: + cur = json.loads(cur) + except json.JSONDecodeError: + verbose_logger.warning( + "SAP service key is a string but not valid JSON." + ) + return None for k in path: if not isinstance(cur, dict) or k not in cur: + verbose_logger.warning( + f"SAP service key has unexpected type '{type(cur).__name__}' (expected dict or JSON string). " + ) return None cur = cur[k] return cur @@ -258,7 +267,7 @@ def validate_credentials( ) def get_token_creator( - service_key: Optional[str] = None, + service_key: Optional[Union[str, dict]] = None, profile: Optional[str] = None, *, expiry_buffer_minutes: int = 60,