diff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.py index 4c4d4c7dab9..f919bc7705d 100644 --- a/litellm/integrations/prometheus.py +++ b/litellm/integrations/prometheus.py @@ -2697,12 +2697,7 @@ class PrometheusLogger(CustomLogger): return None, None def _coerce(value: Any) -> Optional[str]: - if value is None: - return None - inner = getattr(value, "value", None) - if isinstance(inner, str): - return inner - return str(value) + return str(value) if value is not None else None return ( _coerce(getattr(exception, "category", None)), diff --git a/litellm/proxy/common_utils/proxy_rate_limit_error.py b/litellm/proxy/common_utils/proxy_rate_limit_error.py index 14c8977dce6..1c057c5e6e1 100644 --- a/litellm/proxy/common_utils/proxy_rate_limit_error.py +++ b/litellm/proxy/common_utils/proxy_rate_limit_error.py @@ -67,6 +67,8 @@ def map_v3_rate_limit_type( def _coerce_message(detail: Any) -> str: """Best-effort, JSON-friendly stringification of an HTTPException-style detail.""" + if detail is None: + return "" if isinstance(detail, str): return detail if isinstance(detail, Mapping):