Backtrace when adding an invalid IP address with ENFORCE_GLOBAL_UNIQUE #634

Closed
opened 2025-12-29 16:24:06 +01:00 by adam · 0 comments
Owner

Originally created by @candlerb on GitHub (Jan 18, 2017).

This is with netbox 1.8.1

  • Set ENFORCE_GLOBAL_UNIQUE to True
  • Go to page to add a new IP address: /ipam/ip-addresses/add/
  • Enter an invalid or incomplete address e.g. 1.2.3 or 1.2.3.4 (not 1.2.3.4/32)
  • Click "Add"

Instead of a data validation error, I get an exception:

'unicode' object has no attribute 'ip'

With DEBUG=True, I get a backtrace which ends at:

...
/usr/local/lib/python2.7/dist-packages/django/forms/models.py in _post_clean
            self.instance.full_clean(exclude=exclude, validate_unique=False) ...
> Local vars
/usr/local/lib/python2.7/dist-packages/django/db/models/base.py in full_clean
            self.clean() ...
> Local vars
/opt/netbox/netbox/ipam/models.py in clean
            duplicate_ips = IPAddress.objects.filter(vrf=None, address__net_host=str(self.address.ip))\ ...
> Local vars
  Variable    Value
  self        <IPAddress: >
Originally created by @candlerb on GitHub (Jan 18, 2017). This is with netbox 1.8.1 * Set ENFORCE_GLOBAL_UNIQUE to True * Go to page to add a new IP address: /ipam/ip-addresses/add/ * Enter an invalid or incomplete address e.g. `1.2.3` or `1.2.3.4` (not `1.2.3.4/32`) * Click "Add" Instead of a data validation error, I get an exception: ~~~ 'unicode' object has no attribute 'ip' ~~~ With DEBUG=True, I get a backtrace which ends at: ~~~ ... /usr/local/lib/python2.7/dist-packages/django/forms/models.py in _post_clean self.instance.full_clean(exclude=exclude, validate_unique=False) ... > Local vars /usr/local/lib/python2.7/dist-packages/django/db/models/base.py in full_clean self.clean() ... > Local vars /opt/netbox/netbox/ipam/models.py in clean duplicate_ips = IPAddress.objects.filter(vrf=None, address__net_host=str(self.address.ip))\ ... > Local vars Variable Value self <IPAddress: > ~~~
adam added the type: bug label 2025-12-29 16:24:06 +01:00
adam closed this issue 2025-12-29 16:24:06 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#634