mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
security: avoid logging sensitive data in usage dict
- Replace full usage dict logging with keys and type only - Prevents potential exposure of sensitive information in debug logs - Maintains debugging capability without security risk
This commit is contained in:
parent
5401e6d97b
commit
2c5048b7b6
1 changed files with 11 additions and 1 deletions
|
|
@ -4972,7 +4972,17 @@ def _try_create_usage_from_dict(usage: dict) -> Optional[Usage]:
|
|||
try:
|
||||
return Usage(**usage)
|
||||
except (TypeError, ValueError) as e:
|
||||
verbose_logger.debug(f"Error creating Usage from dict: {e}, usage: {usage}")
|
||||
# Avoid logging full dict contents, which may include sensitive data
|
||||
try:
|
||||
usage_keys = list(usage.keys())
|
||||
except Exception:
|
||||
usage_keys = None
|
||||
verbose_logger.debug(
|
||||
"Error creating Usage from dict: %s, usage keys: %s, usage type: %s",
|
||||
e,
|
||||
usage_keys,
|
||||
type(usage),
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue