Skip to content

Commit 4535f9f

Browse files
refactor: raise value error when policy is malformed
1 parent 3a10db0 commit 4535f9f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

openedx_authz/api/permissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def get_permission_from_policy(policy: list[str]) -> PermissionData:
2525
PermissionData: The corresponding PermissionData object or an empty PermissionData if the policy is invalid.
2626
"""
2727
if len(policy) < 4: # Do not count ptype
28-
return PermissionData(action=ActionData(namespaced_key=""), effect="allow")
28+
raise ValueError("Invalid policy format. Expected at least 4 elements.")
2929

3030
return PermissionData(
3131
action=ActionData(namespaced_key=policy[PolicyIndex.ACT.value]),

0 commit comments

Comments
 (0)