Skip to content

JSON serializer issue for Protection Rules defined in configuration.py #18369

@atownson

Description

@atownson

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.1.11

Python Version

3.12

Steps to Reproduce

  1. Create a custom Protection_Rule in the configuration.py. Example:
from extras.validators import CustomValidator

# Prevent IP addresses from being deleted by a cascading delete
class IpAddressProtectionRule(CustomValidator):
    def validate(self, instance, request):
        if hasattr(instance, 'primary_ip') and instance.primary_ip is not None:
            self.fail('This instance has a related IP address(es).')


PROTECTION_RULES = {
    'dcim.device': (
        IpAddressProtectionRule(),
    ),
}
  1. Restart NetBox services
  2. Navigate to Admin -> System

Expected Behavior

The system detail page is returned.

Observed Behavior

An exception is thrown:
image

Metadata

Metadata

Assignees

Labels

severity: mediumResults in substantial degraded or broken functionality for specfic workflowsstatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions