Skip to content

fix(validation): handle array-form permission groups in verify_modes.py - #8

Open
xavier-arosemena wants to merge 2 commits into
jtgsystems:mainfrom
xavier-arosemena:fix/verify-modes-array-form-groups
Open

xavier-arosemena wants to merge 2 commits into
jtgsystems:mainfrom
xavier-arosemena:fix/verify-modes-array-form-groups

Conversation

@xavier-arosemena

Copy link
Copy Markdown

Problem

verify_mode() in scripts/verify_modes.py validates group entries with a set
difference:

invalid_groups = set(groups) - ALLOWED_GROUPS

Roo Code custom modes allow a group entry to be either a permission name or the
array form [edit, {fileRegex, description}], which is explicitly permitted by
schemas/custom_modes.schema.json (definitions.permission) and accepted by
scripts/validate_custom_modes.py (validate_groups()).

When a mode uses that form, groups contains a list, so the set construction
raises and the whole run aborts before any mode is reported:

Traceback (most recent call last):
  File "scripts/verify_modes.py", line 143, in verify_individual_files
    issues.extend(verify_mode(mode, str(rel)))
  File "scripts/verify_modes.py", line 61, in verify_mode
    invalid_groups = set(groups) - ALLOWED_GROUPS
TypeError: unhashable type: 'list'

Reproduction

  1. Add a mode file with groups: [read, [edit, {fileRegex: "^docs/.*\\.md$", description: Docs only}]]
    under custom_modes.d/.
  2. python3 scripts/validate_custom_modes.py <that file> -> exit 0 (accepted).
  3. python3 scripts/verify_modes.py -> TypeError: unhashable type: 'list'.

Fix

Group entries are checked individually: a string entry must be one of the
allowed permission names, and an array entry must be exactly
['edit', {options}]. Malformed array entries are reported as an invalid group
rather than raising.

Verification

Fixture tree (305 real modes plus three fixtures):

fixture before after
[read, [edit, {fileRegex, description}]] run aborts with TypeError no group finding
[read, admin] aborts before reaching it INVALID groups: ['admin']
[read, [edit]] aborts INVALID groups: ["malformed array-form group: ['edit']"]

The existing 305 modes produce no group findings before or after the change.

jtgsystems and others added 2 commits September 3, 2026 01:32
verify_mode() validated group entries with `set(groups) - ALLOWED_GROUPS`.
When a mode uses the array form `[edit, {fileRegex, description}]`, `groups`
contains a list, so the set construction raises:

    TypeError: unhashable type: 'list'

That form is explicitly permitted by schemas/custom_modes.schema.json
(definitions.permission) and is accepted by scripts/validate_custom_modes.py,
so the verifier crashed on input that the validator approves, aborting the
whole run before any mode was reported.

Group entries are now checked individually: a string entry must be one of the
allowed permission names, and an array entry must be exactly
`['edit', {options}]`; anything else is reported as an invalid group instead
of raising.

Verified with a fixture tree containing a valid array-form mode (no INVALID
groups finding), an unsupported permission name (still reported) and a
malformed array entry such as `[edit]` (now reported, previously crashed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants