oliver-zehentleitner / maity

hub: limits: one range table and validator, one override reader, one unlimited conversion; drop ceilings.setter

Sign in to report

tsk-9my6cqexh8ee Open

Audit round 3 (tsk-hgnbapyw7hnh), read at 588f911b. Kind: duplication / dead code.

What is wrong

  • Ranges: hub/src/maity_hub/limits.py:51-70 (RANGES, _checker) and hub/src/maity_hub/limit_overrides.py:27-42 (RANGES, _valid) repeat the same bounds (1-10000 account values, 1 MiB-1 PiB project storage) and the same int-not-bool check.
  • Override rows are read three ways: ceilings.py:59-65 (stored_override), limit_overrides.py:103-106 (_rows), and the target expression again at limit_overrides.py:86.
  • unlimited to a number five times: limits.py:85, :108, :120; read_limits.py:134, :142; ceilings.py:69 (_number, with a type: ignore[call-overload]).
  • Slow admin view: limit_overrides.project_view (:132-137) calls ceilings.ceiling per value, re-reading overrides it already holds; _by (:109-113) runs one handle query per field.
  • Dead: ceilings.setter (ceilings.py:112-114) has no caller in hub/ or web/; routes/project_limits.py:172 computes its own boolean.

Proposal: one range table and validator in limits.py imported by limit_overrides.py; one overrides(conn, project_id|human_id) reader; one cap_of(value) helper without type: ignore; build project_view from the rows already loaded; delete setter.

Effort / risk: M. Low risk.

Notes

  1. Lotse · Nov 21, 2026, 01:58 UTC

    Audit round 4 (tsk-hgnbapyw7hnh, read at 0a1b832e): #1986 added a fourth case of the same pattern.

    • limits.starred (hub/src/maity_hub/limits.py:102-106) is a copy of limits.aliases (limits.py:95-99): store.effective(f"limits.{NAME}", env, store.stored(conn, "limits")) for one bounded cap. One bounded(conn, hub, name) serves both.
    • The bounds 1-8 and 1-1000 are written in config.py (parse_alias_limit, config.py:566-569; parse_bounded(env, "MAITY_MAX_STARRED_PER_HUMAN", 1, 1000), config.py:329) and again in limits.RANGES (limits.py:57-62). parse_alias_limit is now a one-line wrapper with one caller (config.py:328).