Error when editing IP #4187

Closed
opened 2025-12-29 18:33:44 +01:00 by adam · 6 comments
Owner

Originally created by @pboatone on GitHub (Oct 12, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.8.5
  • NetBox version: 2.9.6

Steps to Reproduce

  1. Go to a device
  2. Add an interface "eth0"
    3 Add IP to interface "172.16.3.0/24"
    4 Edit IP -> add a NAT IP(inside) like "192.168.3.0/24"
  3. klick "OK"
  4. Following Error when trying to edit IP:
    2020-10-12 15_07_23-Window
    2020-10-12 15_07_48-Window

Expected Behavior

Expekted is that we want to edit this ip agein.

Observed Behavior

2020-10-12 15_30_38-Window

Originally posted by @pboatone in https://github.com/netbox-community/netbox/issues/5198#issuecomment-707121822

Originally created by @pboatone on GitHub (Oct 12, 2020). Originally assigned to: @jeremystretch on GitHub. ### Environment * Python version: 3.8.5 * NetBox version: 2.9.6 ### Steps to Reproduce 1. Go to a device 2. Add an interface "eth0" 3 Add IP to interface "172.16.3.0/24" 4 Edit IP -> add a NAT IP(inside) like "192.168.3.0/24" 5. klick "OK" 6. Following Error when trying to edit IP: ![2020-10-12 15_07_23-Window](https://user-images.githubusercontent.com/67209365/95752095-cdfa5300-0c9f-11eb-995a-a30aef71b87f.png) ![2020-10-12 15_07_48-Window](https://user-images.githubusercontent.com/67209365/95752103-d3f03400-0c9f-11eb-822b-e1956bc0d3cb.png) ### Expected Behavior Expekted is that we want to edit this ip agein. <!-- What happened instead? --> ### Observed Behavior ![2020-10-12 15_30_38-Window](https://user-images.githubusercontent.com/67209365/95752183-eec2a880-0c9f-11eb-811c-7ce08f91c529.png) _Originally posted by @pboatone in https://github.com/netbox-community/netbox/issues/5198#issuecomment-707121822_
adam added the type: bugstatus: accepted labels 2025-12-29 18:33:44 +01:00
adam closed this issue 2025-12-29 18:33:44 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 12, 2020):

This issue is pending closure as it does not conform to one of the provided templates as required by the contributing guide. If you'd like to request that your issue be re-opened, please first update the content so that it matches the appropriate template (this may require rewriting your issue entirely).

@jeremystretch commented on GitHub (Oct 12, 2020): This issue is pending closure as it does not conform to one of the [provided templates](https://github.com/netbox-community/netbox/issues/new/choose) as required by the [contributing guide](https://github.com/netbox-community/netbox/blob/master/CONTRIBUTING.md). If you'd like to request that your issue be re-opened, please first update the content so that it matches the appropriate template (this may require rewriting your issue entirely).
Author
Owner

@pboatone commented on GitHub (Oct 12, 2020):

Updated post on top

@pboatone commented on GitHub (Oct 12, 2020): Updated post on top
Author
Owner

@DanSheps commented on GitHub (Oct 13, 2020):

Could you include the backtrace (should have been emailed hopefully if you configured that)?

@DanSheps commented on GitHub (Oct 13, 2020): Could you include the backtrace (should have been emailed hopefully if you configured that)?
Author
Owner

@szelga commented on GitHub (Oct 22, 2020):

not the original poster, but have the same (I reckon) problem.

Environment:


Request Method: GET
Request URL: https://netbox.company.name/ipam/ip-addresses/2384/edit/

Django Version: 3.1
Python Version: 3.7.9
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'cacheops',
 'corsheaders',
 'debug_toolbar',
 'django_filters',
 'django_tables2',
 'django_prometheus',
 'mptt',
 'rest_framework',
 'taggit',
 'timezone_field',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'secrets',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'django_rq',
 'drf_yasg']
Installed Middleware:
['debug_toolbar.middleware.DebugToolbarMiddleware',
 'django_prometheus.middleware.PrometheusBeforeMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'utilities.middleware.ExceptionHandlingMiddleware',
 'utilities.middleware.RemoteUserMiddleware',
 'utilities.middleware.LoginRequiredMiddleware',
 'utilities.middleware.APIVersionMiddleware',
 'extras.middleware.ObjectChangeMiddleware',
 'django_prometheus.middleware.PrometheusAfterMiddleware']



Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 73, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 392, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 123, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 101, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 398, in get
    form = self.model_form(instance=obj, initial=initial_data)
  File "/opt/netbox/netbox/ipam/forms.py", line 623, in __init__
    initial['nat_rack'] = nat_inside_parent.device.rack.pk

Exception Type: AttributeError at /ipam/ip-addresses/165/edit/
Exception Value: 'NoneType' object has no attribute 'pk'

Netbox 2.9.7 from official docker image. the IP in question has NAT, and was created in a previous Netbox version (2.9.4, probably). other IPs do not trigger this error.

@szelga commented on GitHub (Oct 22, 2020): not the original poster, but have the same (I reckon) problem. ``` Environment: Request Method: GET Request URL: https://netbox.company.name/ipam/ip-addresses/2384/edit/ Django Version: 3.1 Python Version: 3.7.9 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'cacheops', 'corsheaders', 'debug_toolbar', 'django_filters', 'django_tables2', 'django_prometheus', 'mptt', 'rest_framework', 'taggit', 'timezone_field', 'circuits', 'dcim', 'ipam', 'extras', 'secrets', 'tenancy', 'users', 'utilities', 'virtualization', 'django_rq', 'drf_yasg'] Installed Middleware: ['debug_toolbar.middleware.DebugToolbarMiddleware', 'django_prometheus.middleware.PrometheusBeforeMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'utilities.middleware.ExceptionHandlingMiddleware', 'utilities.middleware.RemoteUserMiddleware', 'utilities.middleware.LoginRequiredMiddleware', 'utilities.middleware.APIVersionMiddleware', 'extras.middleware.ObjectChangeMiddleware', 'django_prometheus.middleware.PrometheusAfterMiddleware'] Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 179, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 73, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 392, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 123, in dispatch return super().dispatch(request, *args, **kwargs) File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 101, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 398, in get form = self.model_form(instance=obj, initial=initial_data) File "/opt/netbox/netbox/ipam/forms.py", line 623, in __init__ initial['nat_rack'] = nat_inside_parent.device.rack.pk Exception Type: AttributeError at /ipam/ip-addresses/165/edit/ Exception Value: 'NoneType' object has no attribute 'pk' ``` Netbox 2.9.7 from official docker image. the IP in question has NAT, and was created in a previous Netbox version (2.9.4, probably). other IPs do not trigger this error.
Author
Owner

@jeremystretch commented on GitHub (Oct 30, 2020):

I'm not able to reproduce this behavior on v2.9.7 using the information provided.

@jeremystretch commented on GitHub (Oct 30, 2020): I'm not able to reproduce this behavior on v2.9.7 using the information provided.
Author
Owner

@bguinet commented on GitHub (Nov 5, 2020):

I have the same problem

Python version: 3.6.9
NetBox version: 2.9.8

Steps to Reproduce :

  1. Create a device without rack reference, add an interface to this device
  2. Create an IP address "IP_In" referencing the newly created interface as Assignment
  3. Create an IP address "IP_Out" referencing an the IP address "IP_In" as its NAT inside "By IP"
  4. Edit the newly created IP address "IP_Out"

Expected Behavior :
User should be presented with the IP edit form

Observed Behavior :
An AttributeError exception is raised:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 73, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 392, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 123, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 101, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 398, in get
    form = self.model_form(instance=obj, initial=initial_data)
  File "/opt/netbox/netbox/ipam/forms.py", line 623, in __init__
    initial['nat_rack'] = nat_inside_parent.device.rack.pk
Exception Type: AttributeError at /ipam/ip-addresses/3547/edit/
Exception Value: 'NoneType' object has no attribute 'pk'

I guess it's related to https://github.com/netbox-community/netbox/issues/5022 and to nat_inside_parent.device.rack wich can be None

@bguinet commented on GitHub (Nov 5, 2020): I have the same problem Python version: 3.6.9 NetBox version: 2.9.8 Steps to Reproduce : 1. Create a device without rack reference, add an interface to this device 2. Create an IP address "IP_In" referencing the newly created interface as Assignment 3. Create an IP address "IP_Out" referencing an the IP address "IP_In" as its NAT inside "By IP" 4. Edit the newly created IP address "IP_Out" Expected Behavior : User should be presented with the IP edit form Observed Behavior : An AttributeError exception is raised: ``` Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 179, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/netbox/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 73, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 392, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 123, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 101, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 398, in get form = self.model_form(instance=obj, initial=initial_data) File "/opt/netbox/netbox/ipam/forms.py", line 623, in __init__ initial['nat_rack'] = nat_inside_parent.device.rack.pk Exception Type: AttributeError at /ipam/ip-addresses/3547/edit/ Exception Value: 'NoneType' object has no attribute 'pk' ``` I guess it's related to https://github.com/netbox-community/netbox/issues/5022 and to nat_inside_parent.device.rack wich can be None
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4187