Don't treat permission name as a machine readable field, use slug instead #115
No reviewers
Labels
No Label
Priority
Critical
Priority
High
Priority
Low
Priority
Normal
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
Type
Breaking
Type
Documentation
Type
Enhancement
Type
Feature
Type
Report
Type
Security
Type
Suggestion
Type
Testing
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: infrastructure/extensions-website#115
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "permissions-use-slug"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #109,
We noticed a discrepancy in behavior between sqlite (case-insensitive like) and postgresql (case-sensitive like) because a lookup was happening against a
name
column, which is titlecased, but the permission ids (slugs) in manifest are lowercase.The fix is to use the
slug
field, and to perform an exact match, not a LIKE.This PR also make sure that slug fields in VersionPermission and License models are unique (doesn't do it for Tag, but we should fix that as well), and cleans up some unused code in the affected models.
@ -407,4 +385,2 @@
@classmethod
def get_by_slug(cls, slug: str):
return cls.objects.filter(slug__startswith=slug).first()
I'm replacing this with an exact match. Was there any usecase to do a prefix match?
I don't recall, if it wasn't explained on the corresponding commit than just assume an exact match should be fine. I think I copied this over from the license and other code snippets
@ -541,3 +517,4 @@
permission = VersionPermission.get_by_slug(permission_name)
# Just ignore versions that are incompatible.
if not permission:
@dfelinto here we explicitly allow to submit a manifest with incorrect permissions names. is it intentional? shouldn't we return a validation error instead if somebody mistypes a permission slug?
Right, it should be an error indeed. Maybe already is (caught early on by the validator)?