You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Errors: cap _map_error response body buffering (memory + log volume) #203
_map_error calls response.json() (which materializes response.content — entire body into memory) and falls back to response.text or f"HTTP {status}". For a normal Kalshi error this is a few hundred bytes, but a misbehaving upstream (intermediate proxy returning a 502 HTML page, a Cloudflare error page in the multi-MB range, or a deliberately oversized response) is buffered in full and then formatted into an exception message.
There is no Content-Length cap, no streaming read with a size limit, and no truncation when constructing the message. The exception then propagates into user logs verbatim — both a memory and a log-volume risk.
Location
kalshi/_base_client.py:38-44
Evidence
# kalshi/_base_client.py:38-44try:
body=response.json() # buffers full bodyexceptException:
body= {}
message=body.get("message") orbody.get("error") orresponse.textorf"HTTP {status}"# message may contain MBs of HTML; flows into KalshiError.args
Activity
fix(transport): Retry-After on 5xx/408 + jittered + success body cap (#…