Summary
Consumer code that iterates a subscribe queue sees except KalshiBackpressureError as e with only str(e) — no way to discriminate which channel/sid/client_id overflowed when multiple subscriptions exist. The error must be parsed from the message string, which is brittle and breaks the structured-error contract #226 established for KalshiSequenceGapError and KalshiSubscriptionError.
Location
kalshi/errors.py:121-122 — bare class, no fields
kalshi/ws/channels.py:537-551 — broadcast site
kalshi/ws/backpressure.py:78-86 — raise site
Evidence
class KalshiBackpressureError(KalshiWebSocketError):
"""Message queue overflow with ERROR strategy."""
# no __init__, no fields
Compare KalshiSequenceGapError which carries channel, sid, client_id, last_seq, next_seq.
Recommended fix
Add __init__ with channel, sid, client_id, maxsize keyword-only fields; populate them at the put() raise site in backpressure.py:78-86 and at the broadcast_error site so the iterator's except block can route by channel.
Severity & category
medium / api-design, ws
Summary
Consumer code that iterates a subscribe queue sees
except KalshiBackpressureError as ewith onlystr(e)— no way to discriminate which channel/sid/client_id overflowed when multiple subscriptions exist. The error must be parsed from the message string, which is brittle and breaks the structured-error contract #226 established forKalshiSequenceGapErrorandKalshiSubscriptionError.Location
kalshi/errors.py:121-122— bare class, no fieldskalshi/ws/channels.py:537-551— broadcast sitekalshi/ws/backpressure.py:78-86— raise siteEvidence
Compare
KalshiSequenceGapErrorwhich carrieschannel,sid,client_id,last_seq,next_seq.Recommended fix
Add
__init__withchannel,sid,client_id,maxsizekeyword-only fields; populate them at theput()raise site inbackpressure.py:78-86and at the broadcast_error site so the iterator'sexceptblock can route by channel.Severity & category
medium / api-design, ws