mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
(fix) handle json decode errors for DD exception logging (#6934)
* fix JSONDecodeError * handle async_log_proxy_authentication_errors * fix test_async_log_proxy_authentication_errors_get_request
This commit is contained in:
parent
77f714dc51
commit
a8b8deb793
2 changed files with 130 additions and 3 deletions
|
@ -891,7 +891,7 @@ class ProxyLogging:
|
|||
original_exception: Exception,
|
||||
request: Request,
|
||||
parent_otel_span: Optional[Any],
|
||||
api_key: str,
|
||||
api_key: Optional[str],
|
||||
):
|
||||
"""
|
||||
Handler for Logging Authentication Errors on LiteLLM Proxy
|
||||
|
@ -905,9 +905,13 @@ class ProxyLogging:
|
|||
|
||||
user_api_key_dict = UserAPIKeyAuth(
|
||||
parent_otel_span=parent_otel_span,
|
||||
token=_hash_token_if_needed(token=api_key),
|
||||
token=_hash_token_if_needed(token=api_key or ""),
|
||||
)
|
||||
request_data = await request.json()
|
||||
try:
|
||||
request_data = await request.json()
|
||||
except json.JSONDecodeError:
|
||||
# For GET requests or requests without a JSON body
|
||||
request_data = {}
|
||||
await self._run_post_call_failure_hook_custom_loggers(
|
||||
original_exception=original_exception,
|
||||
request_data=request_data,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue