oliver-zehentleitner / maity

clean-up: core platform: bug: maity-hub owner create and quickstart accept 32-63 character handles that no project path resolves

Sign in to report

tsk-jwk25nq0e20v Done An agent

From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G1 core platform), read at 9dfd4b65. Paths are under hub/src/maity_hub/ unless named otherwise.

Marked as a bug.

1. Bug: the operator's account commands allow a handle the rest of the hub refuses

  • Kind: bug (one rule implemented twice, differently).
  • Files:
  • cli.py:295 HANDLE = re.compile(r'[a-z0-9][a-z0-9-]{1,62}'), used at cli.py:313-316 (owner create, message "2 to 63 characters") and cli.py:514 (_default_handle, the quickstart default from the login name).
  • Everywhere else a human's handle is [a-z0-9][a-z0-9-]{1,30} (2 to 31): handles.py:32 FORMAT, models.py:10 HANDLE_PATTERN, docs/api.md:2424, docs/humans.md:171, words/en.json:125, web/js/handles.js:13.
  • What is wrong: an account made by maity-hub owner create --handle <32 or more characters>, or by quickstart with a long login name, gets a handle that namespace.FULL_NAME (namespace.py:33, owner part {1,30}) never matches. namespace.resolve (namespace.py:143-145) returns None for every <handle>/<slug>, so each project in that namespace is not_found on every /projects/{owner}/{slug} route. forge_webhook.py:40 has the same {1,30} owner part. No test covers a long handle (hub/tests/test_cli.py).
  • Also: landing.py:68 HANDLE is {1,62} too (the landing setting's list of handles); a handle there longer than 31 characters names nobody.
  • Proposal: validate with handles.FORMAT in cli.py and landing.py, message "2 to 31 characters". Add a test that owner create --handle with 32 characters exits with EXIT_CONFIG. Before the release, check production for a human handle longer than 31 characters.
  • Effort: S
  • Risk: low. Only the operator's CLI path and the landing setting; an existing long handle, if any, needs a rename first.

Covered elsewhere

  • The handle regex compiled in several places, and cli.py re-implementing handles.ensure_free (cli.py:317, :369-370): tsk-hz5nkwyn9sj9 item 9. This card is only the length bug. Do it first, or in the same PR as that item.

Effort sum: S (1 point).