Getting None from tag of DeviceRole #10550

Closed
opened 2025-12-29 21:33:03 +01:00 by adam · 0 comments
Owner

Originally created by @ngotzmann on GitHub (Dec 9, 2024).

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.1.6

Python Version

3.12

Steps to Reproduce

Summary:
I observed the issue on a CustomValidation script. When I try to get the tag from a DeviceRole, it is everytime dcim.DeviceRole.None.

Exect Steps:

  1. Create a Tag
  2. Create a DeviceRole and assign the tag to it
  3. Creating a CustomValidation Script for Devices and enable it in NetBox
from extras.validators import CustomValidator
from dcim.models import DeviceRole

class MyCustomValidator(CustomValidator):
    def validate(self, instance, request):
        fullDeviceRole = DeviceRole.objects.get(slug=instance.role.slug)
        self.fail(fullDeviceRole.tags) # Just for debugging purposes
  1. Try create a Device with your created Device Role
  2. You will get a failing message with dcim.DeviceRole.None instead of your tag name

Expected Behavior

Getting name of the tag.

Observed Behavior

Getting dcim.DeviceRole.None

Originally created by @ngotzmann on GitHub (Dec 9, 2024). ### Deployment Type Self-hosted ### Triage priority N/A ### NetBox Version v4.1.6 ### Python Version 3.12 ### Steps to Reproduce Summary: I observed the issue on a CustomValidation script. When I try to get the tag from a DeviceRole, it is everytime `dcim.DeviceRole.None`. Exect Steps: 1. Create a Tag 2. Create a DeviceRole and assign the tag to it 3. Creating a CustomValidation Script for Devices and enable it in NetBox ```python from extras.validators import CustomValidator from dcim.models import DeviceRole class MyCustomValidator(CustomValidator): def validate(self, instance, request): fullDeviceRole = DeviceRole.objects.get(slug=instance.role.slug) self.fail(fullDeviceRole.tags) # Just for debugging purposes ``` 4. Try create a Device with your created Device Role 5. You will get a failing message with `dcim.DeviceRole.None` instead of your tag name ### Expected Behavior Getting name of the tag. ### Observed Behavior Getting `dcim.DeviceRole.None`
adam closed this issue 2025-12-29 21:33:03 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10550