Repository navigation
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review of the change
Correctness / potential issues
Privilege escalation risk (most important). Adding
WORKSPACEbroadens where this permission is evaluated. If the authorization layer grants access when any scope in the list matches, this permission now applies at the whole-workspace level in addition to the resource level. Confirm this is intentional and that the role list (WORKSPACE_MANAGE,USER) should really get the workspace-wide variant.USERin particular may now pass checks it previously failed.Scope precedence / evaluation order. If scope resolution is order-sensitive (first match wins, or a single "effective scope" is derived), the new first element changes behavior beyond just "adding" a scope. Verify the consumer iterates all scopes (
any(...)) rather than takingscope[0].Deduplication / caching. If the scope list is used as a cache key, serialized into tokens, or persisted in a DB, adding an element invalidates existing entries and may require a data migration or cache bust.
Consistency with sibling permission entries. Check whether other
PermissionMetaentries underCategory.WORKSPACEwithResourcePermissionConst.MODEL_MANAGEalready includeWORKSPACE. If not, this one becomes inconsistent and may indicate the change belongs in a different place (or that several entries need the same adjustment).Tests and snapshots. Any test asserting the exact scope list, role–permission matrices, or serialized permission payloads will need updating. Add a positive test for workspace-level access and a negative test confirming roles that shouldn't gain access still can't.
Trailing comma style. The original had a trailing comma in a single-element list; the new version drops it. Harmless, but keep formatting consistent with the project's linter (e.g., Black would re-add it across two lines).
Minor / optimization suggestions
scopeis never mutated, preferfrozenset/tupleoverlistto prevent accidental in-place changes and to make the value hashable for caching.ordered_unique(...)), so a duplicated scope can't skew precedence logic.Bottom line
The syntax is fine; the change is a semantic broadening of an authorization scope and should be treated as a security-relevant change. Verify the scope evaluation logic, confirm only the intended roles benefit, and update tests/data accordingly.