From 1f0bdb10c1570e90f8cc68b8f2e0c637f9898ea0 Mon Sep 17 00:00:00 2001 From: Vasilisa Parshikova Date: Wed, 11 Mar 2026 16:55:33 +0400 Subject: [PATCH] (sap) fix after bot review --- litellm/llms/sap/credentials.py | 6 +++--- tests/test_litellm/llms/sap/test_sap_fetch_creds.py | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/litellm/llms/sap/credentials.py b/litellm/llms/sap/credentials.py index 61a17332ee6..130d08e6320 100644 --- a/litellm/llms/sap/credentials.py +++ b/litellm/llms/sap/credentials.py @@ -249,17 +249,17 @@ def fetch_credentials(service_key: Optional[Union[str, dict]] = None, profile: O if config.get(f'AICORE_{cv.name.upper()}') is not None else config.get(cv.name))), Source("VCAP service", - lambda cv: _str_or_none( + lambda cv: (_str_or_none( _get_nested(vcap_service, (("credentials",) + cv.vcap_key) if cv.vcap_key else (cv.name,)) ) - if vcap_service else None), # type: ignore[arg-type] + if vcap_service else None)), # type: ignore[arg-type] ] credentials = resolve_credentials(sources) resource_group = resolve_resource_group(sources) - if resource_group: + if resource_group is not None: credentials['resource_group'] = resource_group if 'cert_url' in credentials: diff --git a/tests/test_litellm/llms/sap/test_sap_fetch_creds.py b/tests/test_litellm/llms/sap/test_sap_fetch_creds.py index 4d22ca98485..9121f38eacb 100644 --- a/tests/test_litellm/llms/sap/test_sap_fetch_creds.py +++ b/tests/test_litellm/llms/sap/test_sap_fetch_creds.py @@ -51,6 +51,8 @@ def test_sap_fetch_creds_from_arg_service_key(monkeypatch): def test_fetch_creds_from_env_vcap_service(monkeypatch): _prep_env(monkeypatch) + for var in ("AICORE_CLIENT_ID", "AICORE_CLIENT_SECRET", "AICORE_AUTH_URL", "AICORE_BASE_URL", "AICORE_CERT_URL"): + monkeypatch.delenv(var, raising=False) monkeypatch.setenv("VCAP_SERVICES", json.dumps(mock_sap_vcap_service_key_dict)) creds = sap_credentials.fetch_credentials() assert creds['client_id'] == "vcap-clientid"