Repository navigation
fix(validation): handle array-form permission groups in verify_modes.py - #8
Open
xavier-arosemena wants to merge 2 commits into
Open
xavier-arosemena wants to merge 2 commits into
xavier-arosemena wants to merge 2 commits into
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
verify_mode()inscripts/verify_modes.pyvalidates group entries with a setdifference:
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 byschemas/custom_modes.schema.json(definitions.permission) and accepted byscripts/validate_custom_modes.py(validate_groups()).When a mode uses that form,
groupscontains a list, so the set constructionraises and the whole run aborts before any mode is reported:
Reproduction
groups: [read, [edit, {fileRegex: "^docs/.*\\.md$", description: Docs only}]]under
custom_modes.d/.python3 scripts/validate_custom_modes.py <that file>-> exit 0 (accepted).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 grouprather than raising.
Verification
Fixture tree (305 real modes plus three fixtures):
[read, [edit, {fileRegex, description}]]TypeError[read, admin]INVALID groups: ['admin'][read, [edit]]INVALID groups: ["malformed array-form group: ['edit']"]The existing 305 modes produce no group findings before or after the change.