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

Sign in to report

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, _exchange and Client._send each map URLError/TimeoutError/OSError to "cannot reach ..." and HTTPException to broke_off(...): cli/src/maity/hub.py:417-423, :457-462, :683-695.
  • error_code decides network by 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 the MAITY_ERROR_LINE machine line says - instead of network, and the runner's join_failed detail is null.
  • sign._enc (cli/src/maity/sign.py:64-65) and hub.segment (hub.py:278-280) are the same quote(..., safe="-_.~") one-liner.

Proposal

  • One _unreached(where, exc) -> HubError (or a context manager) that sets HubError.unreached = True, used at the three sites and by broke_off; error_code reads 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

  1. 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 123456 with 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.