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 6a7f6d1
Browse filesBrowse the repository at this point in the historyBrowse files
* docs(planning): audit-correctness change bundle
* fix: catch OverflowError in full_jitter_delay for attempt_index >= 1024
2.0 ** attempt_index raises OverflowError in Python for attempt_index >= 1024
rather than saturating to math.inf as the old docstring claimed. Catch the
OverflowError and clamp the ceiling directly to max_delay, which is the
correct clamped result. Tests added to pin both the no-raise and the exact
max_delay clamp behaviours.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(retry): reorder Retry-After give-up check before budget withdrawal
When a server's Retry-After header exceeds max_delay, the middleware
previously consumed a budget token before giving up, allowing a
Retry-After flood to silently drain shared-budget capacity. Move the
retry_after > max_delay guard before try_withdraw() in both AsyncRetry
and Retry so the token is only spent when a real retry will happen.
Adds test_retry_after_exceeds_max_delay_does_not_consume_budget_token
(async) and …_sync (sync) to pin the invariant.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix: strip userinfo prefix from raw netloc to prevent triple-slash form
For URLs like `http://user:pass@/path` (credentials but no hostname),
the previous reconstruction from `parts.hostname` yielded an empty
netloc, causing `urlunsplit` to emit `http:///path`. Fix by slicing
the `user:pass@` prefix directly off `parts.netloc`; when the remainder
is empty (no real host), reconstruct without an authority section to
produce `http:/path` instead.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(decoders): guard _contains_custom_type against NameError when msgspec absent
When msgspec is not installed, `_contains_custom_type` would raise
`NameError: name 'msgspec' is not defined` rather than the friendly
`ImportError`. Added an early guard that raises `ImportError(MISSING_DEPENDENCY_MESSAGE)`
when `import_checker.is_msgspec_installed` is False, matching the
pattern used in `MsgspecDecoder.__init__`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(resilience): qualify RetryBudget asyncio-safe claim with blocking caveat
The module docstring said "asyncio-safe" without noting that a sync thread
holding the threading.Lock can briefly block the event-loop thread. Added
clarification that the critical section is intentionally tiny to bound
latency, while preserving the core safety guarantee (no torn state).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix: detect sync iterables as non-replayable in _is_streaming_body_async
Factor `_is_replayable_type` shared helper so both async and sync
detectors use the same exclusion list. `_is_streaming_body_async` now
returns True when the body has `__iter__` and is not a replayable type
(bytes/bytearray/memoryview/str/dict/list/tuple), closing the gap where
a sync generator passed to AsyncClient bypassed the streaming-body
marker and the AsyncRetry replay guard.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(middleware): add __all__ to middleware/__init__.py to prevent star-import leakage
Without __all__, `from httpware.middleware import *` would expose Awaitable,
Callable, Protocol, TypeAlias, runtime_checkable, httpx2, chain, and
resilience. Added explicit __all__ listing exactly the 10 public names
(protocols + phase decorators). Tests added to test_public_api.py to guard
this contract.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(retry): catch OverflowError in _parse_retry_after for huge integers
float(int("9" * 400)) raises OverflowError (not ValueError) in Python,
crashing the retry loop when a server sends a pathologically large
Retry-After integer string. Widen the except clause to
(ValueError, OverflowError) so oversized values fall back to jitter
backoff rather than propagating unhandled.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(redaction): unify triple-slash avoidance; reconcile audit-fix gaps
Follow-up reconciliation after the parallel correctness fixes:
- _strip_userinfo's no-host fix only covered the no-query case; _mask_query's
urlunsplit re-introduced http:///path when a sensitive query was masked.
Factor a shared _reassemble() helper used by both, so the empty-authority
triple-slash is avoided everywhere (normal URLs stay byte-identical).
- hoist a function-body import in the msgspec test (ruff PLC0415) and use the
project's # ty: ignore form.
- cover the empty-netloc query/fragment branches, the @-in-path guard, and
mark the never-iterated sync-generator test body no-cover.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
**Lane:** full-ish, but the spec is the [2026-06-14 deep audit](../../../audits/2026-06-14-deep-audit.md)
14
+
(each finding carries root cause + suggested direction), so this bundle is a
15
+
plan-light TDD sweep of the confirmed code-level findings.
16
+
17
+
## Goal
18
+
19
+
Close the confirmed **correctness** and **public-API** findings from the deep
20
+
audit that #62/#63 did not already cover.
21
+
22
+
## Fixes
23
+
24
+
| # | Finding | File | Fix |
25
+
|---|---------|------|-----|
26
+
| L1 | RetryBudget token withdrawn before `Retry-After > max_delay` give-up |`retry.py`| evaluate the give-up guard *before*`budget.try_withdraw()`, in both `AsyncRetry` and `Retry`|
27
+
| L3 |`_parse_retry_after``OverflowError` on huge digit string crashes the loop |`retry.py`| broaden guard to `except (ValueError, OverflowError)`|
28
+
| Nit1 |`full_jitter_delay` raises `OverflowError` at `attempt_index >= 1024` despite docstring claiming saturation |`_backoff.py`| clamp the exponent (or guard the `**`) so the documented `inf`-saturation/`max_delay` clamp actually holds; fix the docstring to match |
29
+
| Nit3 |`_strip_userinfo` emits malformed `http:///path` when authority has creds but no host |`_internal/redaction.py`| when hostname is empty, preserve the original credential-free authority shape instead of a triple-slash URL |
30
+
| Nit6 |`_contains_custom_type` uses bare `msgspec.*` at runtime → `NameError` if msgspec absent |`decoders/msgspec.py`| gate behind `is_msgspec_installed` (raise the friendly `ImportError`) so a direct call without the extra fails cleanly |
31
+
| Nit2 |`_is_streaming_body_async` doesn't mark sync iterables non-replayable (async invariant rests on an undocumented httpx2 detail) |`_internal/status.py`| symmetrize the async detector to also treat sync iterables as streaming bodies, so the replay guard is explicit rather than relying on httpx2 |
32
+
| L2 |`RetryBudget` docstring claims "asyncio-safe" without the blocking caveat |`resilience/budget.py`| qualify the docstring: the `threading.Lock` is correctness-safe but can briefly block the loop thread when shared sync↔async |
33
+
| L8 |`middleware/__init__.py` has no `__all__`, leaking 9+ star-import symbols |`middleware/__init__.py`| add an explicit `__all__` of the ten public names (matches sibling subpackages) |
34
+
35
+
## Verification
36
+
37
+
-[ ] Each fix lands TDD-first (failing test → fix → green); reproducers from the audit drive the tests.
38
+
-[ ] Sync/async parity for L1 (both `Retry` and `AsyncRetry`).
0 commit comments