mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
fix(bugbot): simplify rate-limit label coercion + guard None detail
- prometheus.py _extract_rate_limit_labels: RateLimitError.__init__ already normalizes category/rate_limit_type to plain str, so the getattr(.value) + isinstance dance was dead code. Reduce to str(value) if not None. - proxy_rate_limit_error.py _coerce_message: short-circuit None to '' instead of falling through to str(None) = 'None', which produced the literal message 'litellm.RateLimitError: None'.
This commit is contained in:
parent
a7482095b0
commit
7e8a0779da
2 changed files with 3 additions and 6 deletions
|
|
@ -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)),
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue