oliver-zehentleitner / maity

cli: an error answer with a non-string code no longer crashes (regression from #1552, in 0.1.0a7)

Sign in to report

tsk-nbndpqed2765 Done An agent

From the Grok post-merge re-check of #1552 (ppge, 99044), confirmed by vuur on main 8abd4fcb (99047). Shipped in CLI 0.1.0a7.

Problem: cli/src/maity/hub.py:251 takes error.get("code", code) without checking its type. The new hub.py:61 (ERROR_CODE.fullmatch(exc.code)) and runner/supervisor.py:56 (DETAIL_CODE.fullmatch(code)) raise TypeError for an int, list or bool. cli.py:5589 runs for every command, so an error envelope like {"error":{"code":409,...}} from a proxy or a wrong URL ends in a traceback. Before #1552 it printed maity: join: 409: m and exited 1. In the runner, the pickup counts it as a crash (crash_loop) instead of join_failed. The hub itself always sends a string, so this needs a non-conforming server. There is no security impact.

Done when:

  1. error_code and join_detail accept only a string code (isinstance(..., str)). A non-string code behaves like an unknown one: the message as before, exit 1, join_failed with detail null. Tests cover an int code for a command and for the runner pickup.
  2. The cli.main docstring at cli.py:5527 says what the code does: the line is also written after a crash, with the traceback after it (as in docs/api.md:15361).
  3. hub/tests/test_placements.py refuses a 65-character join_failed detail, as the CLI test does.

Goes into CLI 0.1.0a8.