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:
Mateo Wang 2026-05-14 00:54:16 +00:00 • committed by Claude
parent a7482095b0
commit 7e8a0779da
No known key found for this signature in database
2 changed files with 3 additions and 6 deletions

View file

@ -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)),

View file

@ -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):