oliver-zehentleitner / maity
clean-up: hub-wide: one errors.project_closed helper for the 409 built inline at 13 sites
tsk-p3a14j8p1rg9 Open
From the clean-up audit tsk-hgnbapyw7hnh (finding A4-10, the project_closed part), read at 80647565. Line numbers are at that SHA; check them against current main first. Paths are under hub/src/maity_hub/.
What is wrong
Every site writes the same check and the same error by hand: if <project>.state in CLOSED_STATES: raise ApiError(409, "project_closed", f"the project is {state}"). errors.py already has builders for the common errors (forbidden, invalid, not_found), but none for this one, so the code and message are repeated 13 times.
Sites (git grep at 80647565)
attachments.py:347,group_chats.py:400,invitations.py:552placements.py:974(raisesRefusal, a subclass of ApiError)jourfixe/rounds.py:337(through_refuse, which buildsRefused, a subclass of ApiError)routes/attachments.py:100,:163,routes/board.py:82routes/invitations.py:386(returns the error instead of raising it)routes/placements.py:169(_require_open),routes/restricted.py:328,routes/tasks.py:562,:1653
Not a site: jourfixe/triage.py:416 uses project_closed as a reason string in a payload.
Proposal
errors.project_closed(state) -> ApiErroranderrors.require_open(state), which raises it whenstate in CLOSED_STATES. Use them at all 13 sites.routes/invitations.py:386keeps returning the result ofproject_closed(state).- For the two subclass sites:
placements.Refusaladds nothing over ApiError (tsk-j0vqtv3zhacw item 4), soplacements.py:974can raise the plain error once that lands. Forjourfixe/rounds.py:337, check whether callers catchRefusedspecifically; if they do, keep_refusethere and use only the message builder.
Effort and risk
- Effort S. Risk low: the same status, code and message. Tests assert on the code.
Order
- tsk-j0vqtv3zhacw items 4 and 5 change the same
placements.py:974androutes/placements.py:166-174(_require_openmoves into placements asrequire_open). Do this card after them, or let that move useerrors.require_open. - tsk-thx8zrjc708f item 10 edits
attachments.bind(attachments.py:340-347) next to the first site; rebase rather than conflict.
Covered elsewhere
- The rest of A4-10 (
attachments.used/used_total,attachments_not_configured,store_ofas a check): tsk-thx8zrjc708f item 10. - Searched: project_closed; no card covers the shared error.
Effort sum: S (1 point).
Notes
Maity Coder Claude 003 · Nov 13, 2026, 23:12 UTC
More sites from the clean-up audit (tsk-hgnbapyw7hnh, uncovered-files pass at 9dfd4b65):
tasks.py:562,:1653board.py:82restricted.py:328jourfixe/rounds.py:337routes/invitations.py:386