-
Notifications
You must be signed in to change notification settings - Fork 592
fix: Folder permission cache update sometimes raised TypeError #1539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Folder permission cache update sometimes raised TypeError #1539
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideStandardize folder permission cache to use sets of IDs and adjust the test suite accordingly to fix TypeErrors during cache updates. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `filer/cache.py:32` </location>
<code_context>
-def get_folder_permission_cache(user: UserModel, permission: str) -> typing.Optional[dict]:
+def get_folder_permission_cache(user: UserModel, permission: str) -> typing.Optional[typing.Set[int]]:
"""
Retrieves the cached folder permissions for a given user and permission.
</code_context>
<issue_to_address>
Return type may not match actual cached structure.
The cache currently stores a dict, not a set, so the return type should match. Update the annotation or refactor the cache for consistency.
</issue_to_address>
### Comment 2
<location> `filer/cache.py:89` </location>
<code_context>
+ id_list (set): The set of IDs to set as the new permissions.
"""
- perms = get_folder_permission_cache(user, permission) or {}
+ perms = cache.get(get_folder_perm_cache_key(user, permission)) or {}
perms[user.pk] = id_list
cache.set(get_folder_perm_cache_key(user, permission), perms)
</code_context>
<issue_to_address>
Direct cache access bypasses get_folder_permission_cache logic.
Using cache.get directly may cause issues if get_folder_permission_cache is updated to include extra logic. Please use the getter for consistency, or clarify the reason for direct access.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
perms = cache.get(get_folder_perm_cache_key(user, permission)) or {}
=======
perms = get_folder_permission_cache(user, permission) or {}
>>>>>>> REPLACE
</suggested_fix>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@PeterW-LWL Thank you! I have replaced my PR by your more thorough change! Can you check my single comment? |
Ensure it is a set Co-authored-by: Fabian Braun <fsbraun@gmx.de>
@fsbraun I have accepted your proposed change. |
Description
Fixes #1537
Related resources
TypeError: 'set' object does not support item assignment
#1537Checklist
master
Slack to find a “pr review buddy” who is going to review my pull request.
Summary by Sourcery
Fix TypeError in folder permission cache updates by ensuring the cache stores sets, updating function signatures and docstrings accordingly, and enhancing tests for isolation and overwrite behavior
Bug Fixes:
Enhancements:
Tests: