mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
address greptile review round 2: guard non-dict entry values, move credential injection after debug log
This commit is contained in:
parent
939e378929
commit
19b89b6019
2 changed files with 14 additions and 4 deletions
|
|
@ -1252,16 +1252,17 @@ async def add_litellm_data_to_request( # noqa: PLR0915
|
|||
user_api_key_dict=user_api_key_dict,
|
||||
)
|
||||
|
||||
verbose_proxy_logger.debug(
|
||||
"[PROXY] returned data from litellm_pre_call_utils: %s", data
|
||||
)
|
||||
|
||||
# Team/Project credential overrides from model_config
|
||||
# Placed after the debug log to avoid leaking credential secrets in logs
|
||||
_apply_credential_overrides_from_model_config(
|
||||
data=data,
|
||||
user_api_key_dict=user_api_key_dict,
|
||||
)
|
||||
|
||||
verbose_proxy_logger.debug(
|
||||
"[PROXY] returned data from litellm_pre_call_utils: %s", data
|
||||
)
|
||||
|
||||
## ENFORCED PARAMS CHECK
|
||||
# loop through each enforced param
|
||||
# example enforced_params ['user', 'metadata', 'metadata.generation_name']
|
||||
|
|
@ -1445,6 +1446,8 @@ def _extract_credential_from_entry(entry: dict) -> Optional[str]:
|
|||
Entry structure: {"azure": {"litellm_credentials": "name"}, ...}
|
||||
Returns the first credential name found across all provider keys.
|
||||
"""
|
||||
if not isinstance(entry, dict):
|
||||
return None
|
||||
for provider_config in entry.values():
|
||||
if isinstance(provider_config, dict):
|
||||
credential_name = provider_config.get("litellm_credentials")
|
||||
|
|
|
|||
|
|
@ -1903,6 +1903,13 @@ def test_extract_credential_from_entry_non_dict_value():
|
|||
assert _extract_credential_from_entry(entry) is None
|
||||
|
||||
|
||||
def test_extract_credential_from_entry_non_dict_entry():
|
||||
"""Non-dict entry (e.g. string) should return None, not crash."""
|
||||
assert _extract_credential_from_entry("my-cred-name") is None
|
||||
assert _extract_credential_from_entry(["a", "list"]) is None
|
||||
assert _extract_credential_from_entry(42) is None
|
||||
|
||||
|
||||
# --- Unit tests for _resolve_credential_from_model_config ---
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue