Skip to content

tech-debt(frontend): router meta.minRole is declared and read by no guard #16244

Description

@mrveiss

Found while fixing #14937, which retyped this field to the canonical Role.

autobot-frontend/src/types/router.d.ts declares meta.minRole ("Minimum role required"), but nothing uses it: no route sets it and no guard reads it. I searched both GUIs' src/. The only role gate is meta.admin combined with userStore.isAdmin in router/index.ts. So minRole looks like a working access control but isn't one.

Ask

Wire it in: add a route guard that compares the user's role to minRole by rank.

The backend already ranks roles, in _ROLE_META in autobot_shared/auth/permissions.py:

Role Rank
superadmin 110
admin 100
operator 80
analyst 60
editor 55
user 50
readonly 10

The guard should take its ranking from there rather than from a second hand-written order. Until that guard exists, nothing should rely on minRole for access control.

Refs #14937.

Activity

  1. mrveiss commented on Sep 11, 2026

    @mrveiss
    OwnerAuthor

    Design, starting once PR #16265 merges (it adds Role to the codegen manifest):

  2. added this to the v0.10.0 milestone on Sep 12, 2026
  3. mrveiss commented on Sep 13, 2026

    @mrveiss
    OwnerAuthor

    Post-merge audit: no acceptance criteria in the body, so here is the problem mapped to the fix

    Merged in PR #16489, merge commit 23d9e2b2e, verified on origin/main.

    Problem stated here Fix on main
    meta.minRole is declared and no guard reads it autobot-frontend/src/router/index.ts:1337 resolveMinRoleRedirect takes the strictest minRole across the matched records. The beforeEach at :1420-1423 redirects home when the user doesn't meet it.
    Compare the user's role to minRole by rank autobot-frontend/src/constants/roles.ts:70 meetsMinRole: ROLE_RANK[role] >= ROLE_RANK[minRole]. An unknown or missing role never meets any floor (:71).
    Ranks as in _ROLE_META (superadmin 110 … readonly 10) roles.ts:59 ROLE_RANK has the same seven values.
    Tests autobot-frontend/src/router/__tests__/resolveMinRoleRedirect.test.ts (6 cases); autobot-frontend/src/constants/__tests__/roles.test.ts:40,44

    What's still missing. The issue asked that the guard "take its ranking from there rather than from a second hand-written order". ROLE_RANK is a second hand-written order. roles.test.ts:44 ("matches the backend _ROLE_META ordering exactly") compares it to literal values, not to _ROLE_META. No repo test reads both files: git grep for ROLE_RANK in *.py on origin/main finds nothing. So a change to _ROLE_META in autobot_shared/auth/permissions.py wouldn't fail any check. I'm not reopening, because this issue lists no acceptance criteria. A parity guard between the two needs its own issue.

  4. mrveiss commented on Sep 13, 2026

    @mrveiss
    OwnerAuthor

    The drift gap from the closure audit above (the frontend ROLE_RANK is a hand-typed copy of the backend ranking, and roles.test.ts checks literals only, so a backend re-rank fails nothing) is already tracked in #16491, which folds ROLE_RANK into gen_frontend_types.py the same way Permission and Role are generated. No separate issue is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions