oliver-zehentleitner / maity
cli + runner: one 'value in code form' helper and one forbidden-reason rule for error_code, join_detail and refusal_line
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_codetwice (cli/src/maity/hub.py:64and:67),supervisor.join_detailtwice (runner/supervisor.py:65and:67), andsupervisor._code_or_dash(runner/supervisor.py:70-74, added by #2055). - The rule 'for
forbidden, the reason indetails.reasonstands for the code' is implemented twice:hub.error_code(hub.py:66-68, returnsforbidden <reason>) andsupervisor.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 onhub.ERROR_CODE(hub.py:54), whichsupervisor.DETAIL_CODE(supervisor.py:54) aliases.
Proposal
hub.code_or(value, default)(oras_code(value) -> str | None) used by all five sites, and onehub.refusal_code(code, details)thaterror_codeandjoin_detailformat from. Build_ERROR_LINEfromERROR_CODE.pattern; drop theDETAIL_CODEalias.
Effort / risk: S. Low; test_supervisor, test_wait_retry and test_cli cover the machine line and join details.