-
Notifications
You must be signed in to change notification settings - Fork 372
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: Reading role permissions generates 500 error backend #3079
fix: Reading role permissions generates 500 error backend #3079
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Uffizzi Preview |
api/users/models.py
Outdated
def get_user_roles(self): | ||
user_roles = UserRole.objects.filter(user=self) | ||
return user_roles |
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.
If settings.IS_RBAC_INSTALLED
is not present then this method will throw an error. Maybe catch the exception and fire a custom error to stop it from looking like a random 500 error?
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.
Done.
if settings.IS_RBAC_INSTALLED: | ||
roles = UserRoleSerializer(many=True, read_only=True, source="get_user_roles") |
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.
I don't really like the if-statement that leads to roles not being set on the serializer. Is this how we do it throughout the codebase? I feel like defaulting roles
to None
would look better.
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.
I don't think this is possible since UserRoleSerializer lives in RBAC.
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.
Ok makes sense.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #3079 +/- ##
==========================================
- Coverage 95.89% 95.87% -0.02%
==========================================
Files 1039 1039
Lines 30721 30776 +55
==========================================
+ Hits 29459 29508 +49
- Misses 1262 1268 +6 ☔ View full report in Codecov by Sentry. |
if settings.IS_RBAC_INSTALLED: | ||
roles = UserRoleSerializer(many=True, read_only=True, source="get_user_roles") |
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.
Ok makes sense.
)" This reverts commit cee607a.
Thanks for submitting a PR! Please check the boxes below:
pre-commit
to check lintingdocs/
if required so people know about the feature!Changes
How did you test this code?