Repository navigation
Commit 7c8fb86
fix(http): fail fast when no HTTP client is available (PAL code-review)
A 3-model PAL review of the 0.8.2 changes flagged that the Phase 5
NetworkError("No HTTP client available") raise (added when a get/get_sync
has neither an adafruit session nor urllib) was raised INSIDE the retry
loop, so the broad `except Exception` caught it and retried 3× with
backoff — burning up to ~6s of real time.sleep on the sync path for a
permanent, un-retryable configuration state. post()'s no-client path
also fell through to `self.urllib.Request(...)` with urllib=None, whose
AttributeError got wrapped into a confusing NetworkError message.
Add a fail-fast preflight (no adafruit session AND no urllib -> raise
NetworkError immediately) before the retry loop in get()/get_sync() and
before the try in post(). Desktop always has urllib, so this path only
triggers on a genuinely clientless CircuitPython config; existing tests
are unaffected (verified: 698 lib + 95 app green). Adds
TestNoHttpClientFailsFast covering all three entry points (asserts no
retry sleep, and post() raises a clean "No HTTP client available").
Also fixes a stale post() docstring that still referenced the removed
`.error` response attribute.
The review confirmed the load-bearing invariants held: EBUSY socket
detach/close preserved, OTA (ok, reason) tuple contract intact, the
web-settings flag handoff sound, and the shared sim-backend wiring order
correct.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 2a181e1 commit 7c8fb86
2 files changed
Lines changed: 57 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
210 | 216 | | |
211 | 217 | | |
212 | 218 | | |
| |||
383 | 389 | | |
384 | 390 | | |
385 | 391 | | |
386 | | - | |
| 392 | + | |
| 393 | + | |
387 | 394 | | |
388 | 395 | | |
389 | 396 | | |
| |||
392 | 399 | | |
393 | 400 | | |
394 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
395 | 407 | | |
396 | 408 | | |
397 | 409 | | |
| |||
438 | 450 | | |
439 | 451 | | |
440 | 452 | | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
441 | 458 | | |
442 | 459 | | |
443 | 460 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
0 commit comments