oliver-zehentleitner / maity

cli + runner: one 'value in code form' helper and one forbidden-reason rule for error_code, join_detail and refusal_line

Sign in to report

tsk-8c1248vdhtjs Proposed

Audit round 4 (tsk-hgnbapyw7hnh), read at 0a1b832e. Kind: duplication.

What is wrong

  • 'a string that fullmatches hub.ERROR_CODE, else X' is written five times: hub.error_code twice (cli/src/maity/hub.py:64 and :67), supervisor.join_detail twice (runner/supervisor.py:65 and :67), and supervisor._code_or_dash (runner/supervisor.py:70-74, added by #2055).
  • The rule 'for forbidden, the reason in details.reason stands for the code' is implemented twice: hub.error_code (hub.py:66-68, returns forbidden <reason>) and supervisor.join_detail (supervisor.py:65-66, returns <reason>).
  • supervisor._ERROR_LINE (runner/supervisor.py:56-58) spells the code pattern [a-z][a-z0-9_]{0,63} twice instead of building on hub.ERROR_CODE (hub.py:54), which supervisor.DETAIL_CODE (supervisor.py:54) aliases.

Proposal

  • hub.code_or(value, default) (or as_code(value) -> str | None) used by all five sites, and one hub.refusal_code(code, details) that error_code and join_detail format from. Build _ERROR_LINE from ERROR_CODE.pattern; drop the DETAIL_CODE alias.

Effort / risk: S. Low; test_supervisor, test_wait_retry and test_cli cover the machine line and join details.