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
Commit 0b349b2
Browse filesBrowse the repository at this point in the historyBrowse files
Collapses 6 hand-duplicated _reconstruct_X + __reduce__ pairs in errors.py
(RetryBudgetExhaustedError, BulkheadFullError, CircuitOpenError,
DecodeError, MissingDecoderError, ResponseTooLargeError) into one shared
_KeywordReduceMixin + _reconstruct_kwonly function. Deliberately not
applied to ClientError itself, which would silently break pickling for
TransportError/NetworkError/TimeoutError. StatusError's own reduce
mechanism stays untouched. No test changes — the 6 existing pickle
round-trip tests already exercise the shared mixin and verify unpickling.
Design: planning/changes/2026-07-13.03-errors-keyword-reduce-mixin.md
Copy file name to clipboardExpand all lines: architecture/errors.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,8 @@ The error-mapping table (what `httpx2` exception maps to which `httpware` except
18
18
19
19
The "no `__init__` override" rule scopes only to `StatusError` subclasses. Non-status `ClientError` subclasses — `DecodeError`, `MissingDecoderError`, `BulkheadFullError`, `RetryBudgetExhaustedError`, `CircuitOpenError`, `ResponseTooLargeError` — deliberately define `__init__` with keyword-only fields.
20
20
21
+
These six non-status `ClientError` subclasses inherit `__reduce__` from `_KeywordReduceMixin`, which pickles via `self.__dict__` and reconstructs via `cls(**kwargs)`. This requires `self.__dict__` to exactly mirror the `__init__` keyword parameters: an attribute stored beyond those parameters raises `TypeError` on unpickle (unexpected keyword argument), and a keyword parameter `__init__` doesn't assign to `self` is silently dropped if it has a default (unpickle reverts to it) or raises `TypeError` if it doesn't.
22
+
21
23
`ResponseTooLargeError` is raised when `max_response_body_bytes` is set and a response body would exceed the cap — status-agnostic (a `200` can trip it), counting **decoded** bytes. It fires from the non-streaming terminal (`send()`) and from `stream()`'s internal error pre-read; user-driven `stream()` iteration is never capped. The `reason` field discriminates the two trip modes: `"declared"` (the declared `Content-Length` already exceeds the cap, rejected before any byte is read — `content_length` holds it) and `"streamed"` (the decoded body crossed the cap mid-read, the chunked or compression-bomb case, where the true size is unknown by design). It is a non-status `ClientError`; it does not carry a `StatusError`-style positional `response` and is not in `STATUS_TO_EXCEPTION`. Because it is neither a `StatusError`, `NetworkError`, nor `TimeoutError`, it is not retried and does not count toward the circuit breaker.
22
24
23
25
## Security: request headers are reachable via `exc.response.request`
0 commit comments