mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
(sap) fix after bot review
This commit is contained in:
parent
f50c106400
commit
00632d310a
3 changed files with 15 additions and 7 deletions
0
litellm/llms/sap/__init__.py
Normal file
0
litellm/llms/sap/__init__.py
Normal file
|
|
@ -226,6 +226,9 @@ def _parse_service_key_once(
|
|||
"SAP service key is a string but not valid JSON. Skipping this source."
|
||||
)
|
||||
return None
|
||||
verbose_logger.warning(
|
||||
f"SAP service key has unexpected type '{type(service_key).__name__}'. Expected str or dict. Ignoring."
|
||||
)
|
||||
return None
|
||||
|
||||
def _resolve_credential_from_service_key(
|
||||
|
|
@ -484,11 +487,16 @@ def get_token_creator(
|
|||
cert_pair=(cert_path, key_path),
|
||||
)
|
||||
# Case 3: file-based cert/key
|
||||
return _request_token(
|
||||
auth_url=auth_url,
|
||||
client_id=client_id,
|
||||
timeout=timeout,
|
||||
cert_pair=(cert_file_path, key_file_path),
|
||||
if cert_file_path and key_file_path:
|
||||
return _request_token(
|
||||
auth_url=auth_url,
|
||||
client_id=client_id,
|
||||
timeout=timeout,
|
||||
cert_pair=(cert_file_path, key_file_path),
|
||||
)
|
||||
# Defensive guard: should never reach here due to validate_credentials()
|
||||
raise ValueError(
|
||||
"Invalid authentication configuration: no valid credentials found. "
|
||||
)
|
||||
|
||||
def get_token() -> str:
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ def test_partial_credentials_missing_auth_url(monkeypatch):
|
|||
creds = sap_credentials.fetch_credentials()
|
||||
creds.pop('resource_group')
|
||||
|
||||
with pytest.raises(ValueError, match="SAP AI Core credentials not found."):
|
||||
with pytest.raises(ValueError, match="SAP AI Core credentials not found"):
|
||||
sap_credentials.validate_credentials(**creds)
|
||||
|
||||
def test_credentials_without_authentication_mode(monkeypatch):
|
||||
|
|
@ -138,5 +138,5 @@ def test_credentials_without_authentication_mode(monkeypatch):
|
|||
creds.pop('resource_group')
|
||||
|
||||
# validate_credentials should raise because no authentication mode is provided
|
||||
with pytest.raises(ValueError, match="SAP AI Core credentials are incomplete."):
|
||||
with pytest.raises(ValueError, match="SAP AI Core credentials are incomplete"):
|
||||
sap_credentials.validate_credentials(**creds)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue