Skip to content

Commit 30bfed1

Browse files
committed
Validate action name is not empty and clarify RESERVED_ACTIONS origin
1 parent 0508f7a commit 30bfed1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

netbox/users/constants.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
CONSTRAINT_TOKEN_USER = '$user'
1212

13-
# Built-in actions that receive special handling (dedicated checkboxes, model properties)
14-
# and should not be registered as custom model actions.
13+
# Django's four default model permissions. These receive special handling
14+
# (dedicated checkboxes, model properties) and should not be registered
15+
# as custom model actions.
1516
RESERVED_ACTIONS = ('view', 'add', 'change', 'delete')
1617

1718
# API tokens

netbox/utilities/permissions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def register_model_actions(model: type[Model], actions: list[ModelAction | str])
5353
for action in actions:
5454
if isinstance(action, str):
5555
action = ModelAction(name=action)
56+
if not action.name:
57+
raise ValueError("Action name must not be empty.")
5658
if action.name in RESERVED_ACTIONS:
5759
raise ValueError(f"'{action.name}' is a reserved action and cannot be registered.")
5860
if action not in registry['model_actions'][label]:

0 commit comments

Comments
 (0)