From 6ac5afc0e9698213827745ba00e1d25068d5c477 Mon Sep 17 00:00:00 2001 From: Jason Novinger Date: Mon, 30 Mar 2026 12:32:57 -0500 Subject: [PATCH] Validate action name is not empty and clarify RESERVED_ACTIONS origin --- netbox/users/constants.py | 5 +++-- netbox/utilities/permissions.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/netbox/users/constants.py b/netbox/users/constants.py index 982e69868..744ec0f92 100644 --- a/netbox/users/constants.py +++ b/netbox/users/constants.py @@ -10,8 +10,9 @@ OBJECTPERMISSION_OBJECT_TYPES = ( CONSTRAINT_TOKEN_USER = '$user' -# Built-in actions that receive special handling (dedicated checkboxes, model properties) -# and should not be registered as custom model actions. +# Django's four default model permissions. These receive special handling +# (dedicated checkboxes, model properties) and should not be registered +# as custom model actions. RESERVED_ACTIONS = ('view', 'add', 'change', 'delete') # API tokens diff --git a/netbox/utilities/permissions.py b/netbox/utilities/permissions.py index f27531936..49177af9f 100644 --- a/netbox/utilities/permissions.py +++ b/netbox/utilities/permissions.py @@ -53,6 +53,8 @@ def register_model_actions(model: type[Model], actions: list[ModelAction | str]) for action in actions: if isinstance(action, str): action = ModelAction(name=action) + if not action.name: + raise ValueError("Action name must not be empty.") if action.name in RESERVED_ACTIONS: raise ValueError(f"'{action.name}' is a reserved action and cannot be registered.") if action not in registry['model_actions'][label]: