-
-
Notifications
You must be signed in to change notification settings - Fork 41
fix: replace CheckFailure with PermissionLevelError in SnippetsBaseCog #998
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
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Deploying tux with
|
| Latest commit: |
43d7a10
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://63b0fb49.tux-afh.pages.dev |
| Branch Preview URL: | https://snippet-permissions-fix.tux-afh.pages.dev |
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
|
this seems dependent on LIMIT_TO_ROLE_IDS being false, which could explain this. |
Reviewer's GuideThis PR fixes the mod-check logic in the SnippetsBaseCog by importing and catching the specific PermissionLevelError instead of the generic CheckFailure, ensuring non-mod users are correctly handled when creating snippets. Sequence diagram for permission check in check_if_user_has_mod_overridesequenceDiagram
participant User as actor User
participant Bot as SnippetsBaseCog
participant Checks as checks.has_pl(2)
participant Exception as PermissionLevelError
User->>Bot: invoke command
Bot->>Checks: has_pl(2).predicate(ctx)
alt User is not a mod
Checks-->>Bot: raise PermissionLevelError
Bot->>Bot: return False
else User is a mod
Checks-->>Bot: success
Bot->>Bot: continue
end
Class diagram for updated exception handling in SnippetsBaseCogclassDiagram
class SnippetsBaseCog {
+check_if_user_has_mod_override(ctx)
}
class commands.CheckFailure
class PermissionLevelError
SnippetsBaseCog ..> PermissionLevelError : catches
SnippetsBaseCog ..> commands.CheckFailure : (no longer catches)
File-Level Changes
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 @electron271 - I've reviewed your changes - here's some feedback:
- Ensure any other permission checks that previously caught commands.CheckFailure are updated to catch PermissionLevelError for consistency across the codebase.
- Verify that checks.has_pl only raises PermissionLevelError and not other CheckFailure-derived exceptions to avoid unhandled cases.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Ensure any other permission checks that previously caught commands.CheckFailure are updated to catch PermissionLevelError for consistency across the codebase.
- Verify that checks.has_pl only raises PermissionLevelError and not other CheckFailure-derived exceptions to avoid unhandled cases.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
okay so i think this might be some weird edge case, either way fixed |
meatharvester
left a comment
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.
everything appears to be good and dosent introduce any unwanted side effects
Description
fixes an issue where users cant make snippets if they arent a mod
Guidelines
My code follows the style guidelines of this project (formatted with Ruff)
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation if needed
My changes generate no new warnings
I have tested this change
Any dependent changes have been merged and published in downstream modules
I have added all appropriate labels to this PR
I have followed all of these guidelines.
How Has This Been Tested? (if applicable)
had an user who wasnt a mod make a snippet before and after, worked after
Screenshots (if applicable)
Please add screenshots to help explain your changes.
Additional Information
Please add any other information that is important to this PR.
Summary by Sourcery
Bug Fixes: