Repository navigation
Description
PyserialMonitor.write converts serial.SerialException into RuntimeError("Serial write error: ...") (ci/util/pyserial_monitor.py:222). RpcClient.send retries only RpcTimeoutError (ci/rpc_client.py:437), so that RuntimeError propagates out of send unchanged — past its own documented contract, which promises RpcTimeoutError or RpcError.
Every caller that handles RPC failure by catching (RpcError, RpcTimeoutError) therefore misses a failed write. Found in _settle_link in the peer-OTA path (#4178), where it meant no retry and an error naming neither the board nor the call. Worked around there by widening that one except tuple; the general case is still open.
Why it wasn't fixed at the boundary
Normalizing inside send is the right home for it, but it is not a contained change:
- 31 modules import
RpcClient. - Some rely on a bare
except RuntimeErrorto report transport failures cleanly.ci/autoresearch/decode.py:258and:356are the clear ones — they printError: ...and return 1. Normalizing toRpcError(which derives fromException, notRuntimeError) would turn those clean exits into tracebacks.
Options
-
Make
RpcErrorinherit fromRuntimeError, then normalize insend.RpcTimeoutErroralready subclasses the builtinTimeoutError, so there is precedent in the same file. Existingexcept RuntimeErrorhandlers keep working and existingexcept RpcErrorhandlers keep working, so the normalization becomes safe everywhere. The behaviour change is that code catchingRuntimeErrornow also catchesRpcError— a widening, which is what makes it safe, but it does mean anything deliberately lettingRpcErrorpast aRuntimeErrorhandler would change. I did not audit all 31 modules for that. -
Normalize in
sendand fix the callers. More explicit, more churn, and easy to miss one. -
Leave it and widen except tuples at each call site. What fix(autoresearch): name the board that failed the peer-OTA handshake (#3956) #4178 does. Works, but every caller has to know a transport detail that
sendshould be hiding.
Option 1 looks best to me, but it touches a shared error type across the autoresearch tree, so it wants a maintainer's call rather than mine.
Reproducing
Any RPC call while the serial port drops. In a unit test:
client.send = AsyncMock(side_effect=RuntimeError("Serial write error: boom"))against a caller catching (RpcError, RpcTimeoutError) — the error escapes.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(rpc): normalize serial transport failures into RpcError (#4191) (#…
fix(autoresearch): a failed write is not an error reply (#4207)
fix(autoresearch): refuse a connected-but-inert RpcBench (#4207) (#4252)