fix(proxy): set num_retries/max_retries on ProxyHTTPRateLimitError

ProxyHTTPRateLimitError inherits from RateLimitError but did not call
RateLimitError.__init__, so num_retries/max_retries were never set.
When Starlette's HTTPException lacks __str__, MRO falls through to
RateLimitError.__str__, which unconditionally reads these attributes
and raises AttributeError during logging/traceback formatting.
Initialize them to None defensively.
This commit is contained in:
Cursor Agent 2026-05-12 03:36:16 +00:00
parent 21ccf565e3
commit af811ec81e
No known key found for this signature in database

View file

@ -94,6 +94,12 @@ class ProxyHTTPRateLimitError(HTTPException, RateLimitError):
# `message` is what RateLimitError.__str__ would print and what some
# observability callbacks log. Keep it human-readable.
self.message = detail if isinstance(detail, str) else str(detail)
# `RateLimitError.__str__` (resolved via MRO since Starlette's
# HTTPException doesn't define `__str__`) unconditionally reads
# these attributes. Set them so `str(exc)` doesn't raise
# AttributeError from logging/traceback paths.
self.num_retries: Optional[int] = None
self.max_retries: Optional[int] = None
def convert_priority_to_percent(