oliver-zehentleitner / maity
cli: one transport-error mapping in hub.py with an explicit unreached flag (a broken-off answer is network, not -); one path-segment encoder
tsk-b6083ktng3dw Done Maity Coder Claude 003
Audit round 3b (tsk-hgnbapyw7hnh), read at 80fef076. Kind: duplication / small correctness drift.
What is wrong
get_text,_exchangeandClient._sendeach mapURLError/TimeoutError/OSErrorto "cannot reach ..." andHTTPExceptiontobroke_off(...):cli/src/maity/hub.py:417-423,:457-462,:683-695.error_codedecidesnetworkby message text:str(exc).startswith("cannot reach ")(hub.py:61).broke_off(hub.py:426-430), whose docstring calls it "a lost connection like any other", builds "<where> broke off its answer (...)", so for a cut-off answer theMAITY_ERROR_LINEmachine line says-instead ofnetwork, and the runner'sjoin_faileddetail is null.sign._enc(cli/src/maity/sign.py:64-65) andhub.segment(hub.py:278-280) are the samequote(..., safe="-_.~")one-liner.
Proposal
- One
_unreached(where, exc) -> HubError(or a context manager) that setsHubError.unreached = True, used at the three sites and bybroke_off;error_codereads the flag. - One public segment encoder, used by both modules.
Effort / risk: S. Low; texts stay, only the machine code for a broken-off answer changes from - to network.
Notes
Maity Test Team · Nov 20, 2026, 19:11 UTC
Tester result (mmza): pass. Build: local main at 398596aa1 (cli/src from git archive, run with the pipx venv's Python); not the installed CLI (0.1.0a10). No prod contact.
Fake local hub on 127.0.0.1 answering
maity join http://127.0.0.1:<port>/join/abc --code 123456with a fresh MAITY_STATE_DIR and MAITY_ERROR_LINE=<32-hex nonce>:- Body cut short (Content-Length 500, 5 bytes sent, close): "…/api/v1/join/<token> broke off its answer (IncompleteRead)", then
maity-error <nonce>: network. - Garbage status line: "… broke off its answer (BadStatusLine)", then
maity-error <nonce>: network. - Refused port: "cannot reach …: [Errno 111] Connection refused", then
maity-error <nonce>: network(unchanged). - Without MAITY_ERROR_LINE: only the human line, no machine line.
Human texts match the PR. For contrast, the installed 0.1.0a10 crashes with a raw IncompleteRead / BadStatusLine traceback against the same fake hub (old code path, fixed on main).
Side observation, not a defect of this card: join warns "this machine already holds an identity on join.maity.team" even with an empty MAITY_STATE_DIR, so the identity check looks beyond the state dir.- Body cut short (Content-Length 500, 5 bytes sent, close): "…/api/v1/join/<token> broke off its answer (IncompleteRead)", then