IP objects with NAT throws error when trying to edit them #1005

Closed
opened 2025-12-29 16:27:45 +01:00 by adam · 5 comments
Owner

Originally created by @r-bhikhie on GitHub (May 31, 2017).

Issue type: bug report

Python version: Python 2.7.9 (default, Sep 17 2016, 20:26:04)
NetBox version: Release v2.0.4 commit f7b0d22f86
Django version: Version: 1.11.1
nginx version: nginx/1.6.2
Gunicorn version: gunicorn (version 19.7.1)

Steps to recreate:

-Log in with user account
-Click IP space > IP Addresses
-Go to page 3
-Click the IP address of the object (/ipam/ip-addresses/203/)
-Click "Edit This IP" on the right hand side
-Error appears:
<type 'exceptions.AttributeError'>

'NoneType' object has no attribute 'site'

The object in question, I've tried to pull it from the API pages:

GET /api/ipam/ip-addresses/?family=&id__in=203&q=&parent=&mask_length=
HTTP 200 OK
Allow: GET, POST, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 203,
            "family": 4,
            "address": "192.168.1.10/32",
            "vrf": null,
            "tenant": null,
            "status": {
                "value": 1,
                "label": "Active"
            },
            "interface": null,
            "description": "pFSense VM - WAN",
            "nat_inside": {
                "id": 359,
                "url": "http://192.168.1.85/api/ipam/ip-addresses/359/",
                "family": 4,
                "address": "172.16.0.1/32"
            },
            "nat_outside": null,
            "custom_fields": {}
        }
    ]
}

Originally created by @r-bhikhie on GitHub (May 31, 2017). <!-- Please note: GitHub issues are to be used only for feature requests and bug reports. For installation assistance or general discussion, please join us on the mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please indicate "bug report" or "feature request" below. Be sure to search the existing set of issues (both open and closed) to see if a similar issue has already been raised. --> ### Issue type: bug report <!-- If filing a bug, please indicate the version of Python and NetBox you are running. (This is not necessary for feature requests.) --> **Python version: Python 2.7.9 (default, Sep 17 2016, 20:26:04)** **NetBox version: Release v2.0.4** *commit f7b0d22f86deff8e5cb5750a21e71838bfd4d41b* **Django version: Version: 1.11.1** **nginx version: nginx/1.6.2** **Gunicorn version: gunicorn (version 19.7.1)** <!-- If filing a bug, please record the exact steps taken to reproduce the bug and any errors messages that are generated. --> #### Steps to recreate: -Log in with user account -Click IP space > IP Addresses -Go to page 3 -Click the IP address of the object (/ipam/ip-addresses/203/) -Click "Edit This IP" on the right hand side -Error appears: `<type 'exceptions.AttributeError'>` ` ` `'NoneType' object has no attribute 'site'` The object in question, I've tried to pull it from the API pages: ``` GET /api/ipam/ip-addresses/?family=&id__in=203&q=&parent=&mask_length= ``` ``` HTTP 200 OK Allow: GET, POST, HEAD, OPTIONS Content-Type: application/json Vary: Accept { "count": 1, "next": null, "previous": null, "results": [ { "id": 203, "family": 4, "address": "192.168.1.10/32", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": null, "description": "pFSense VM - WAN", "nat_inside": { "id": 359, "url": "http://192.168.1.85/api/ipam/ip-addresses/359/", "family": 4, "address": "172.16.0.1/32" }, "nat_outside": null, "custom_fields": {} } ] } ```
adam added the type: bug label 2025-12-29 16:27:45 +01:00
adam closed this issue 2025-12-29 16:27:45 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 31, 2017):

I'm not able to replicate this. Can you set DEBUG=True in configuration.py and try again? Please post the full stack trace from the error it yields.

@jeremystretch commented on GitHub (May 31, 2017): I'm not able to replicate this. Can you set `DEBUG=True` in configuration.py and try again? Please post the full stack trace from the error it yields.
Author
Owner

@r-bhikhie commented on GitHub (Jun 1, 2017):

Is this the correct part?

Environment:


Request Method: GET
Request URL: http://192.168.1.85/ipam/ip-addresses/3/edit/

Django Version: 1.11.1
Python Version: 2.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',
 'corsheaders',
 'debug_toolbar',
 'django_filters',
 'django_tables2',
 'mptt',
 'rest_framework',
 'rest_framework_swagger',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'secrets',
 'tenancy',
 'users',
 'utilities')
Installed Middleware:
('debug_toolbar.middleware.DebugToolbarMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'utilities.middleware.LoginRequiredMiddleware',
 'utilities.middleware.APIVersionMiddleware')



Traceback:

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/mixins.py" in dispatch
  92.         return super(PermissionRequiredMixin, self).dispatch(request, *args, **kwargs)

File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/opt/netbox/netbox/utilities/views.py" in get
  181.         form = self.form_class(instance=obj, initial=initial_data)

File "/opt/netbox/netbox/ipam/forms.py" in __init__
  445.             initial['nat_site'] = instance.nat_inside.device.site

Exception Type: AttributeError at /ipam/ip-addresses/3/edit/
Exception Value: 'NoneType' object has no attribute 'site'
@r-bhikhie commented on GitHub (Jun 1, 2017): Is this the correct part? ``` Environment: Request Method: GET Request URL: http://192.168.1.85/ipam/ip-addresses/3/edit/ Django Version: 1.11.1 Python Version: 2.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', 'corsheaders', 'debug_toolbar', 'django_filters', 'django_tables2', 'mptt', 'rest_framework', 'rest_framework_swagger', 'circuits', 'dcim', 'ipam', 'extras', 'secrets', 'tenancy', 'users', 'utilities') Installed Middleware: ('debug_toolbar.middleware.DebugToolbarMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'utilities.middleware.LoginRequiredMiddleware', 'utilities.middleware.APIVersionMiddleware') Traceback: File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in view 68. return self.dispatch(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/mixins.py" in dispatch 92. return super(PermissionRequiredMixin, self).dispatch(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in dispatch 88. return handler(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py" in get 181. form = self.form_class(instance=obj, initial=initial_data) File "/opt/netbox/netbox/ipam/forms.py" in __init__ 445. initial['nat_site'] = instance.nat_inside.device.site Exception Type: AttributeError at /ipam/ip-addresses/3/edit/ Exception Value: 'NoneType' object has no attribute 'site' ```
Author
Owner

@jeremystretch commented on GitHub (Jun 1, 2017):

Yes, that's it. Thanks.

@jeremystretch commented on GitHub (Jun 1, 2017): Yes, that's it. Thanks.
Author
Owner

@r-bhikhie commented on GitHub (Jun 9, 2017):

The issue is still present in 2.0.5.

I tried to set the NAT element to "null" via some clicking in the API, that made the object editable again.
Adding the NAT entry for "172.31.0.1/32" again via the GUI breaks the object as I described before.

@r-bhikhie commented on GitHub (Jun 9, 2017): The issue is still present in 2.0.5. I tried to set the NAT element to "null" via some clicking in the API, that made the object editable again. Adding the NAT entry for "172.31.0.1/32" again via the GUI breaks the object as I described before.
Author
Owner

@chrisintheshell commented on GitHub (Jun 9, 2017):

I'm getting this same issue on 2.0.4. I haven't yet upgraded to 2.0.5 but will give it a shot.

@chrisintheshell commented on GitHub (Jun 9, 2017): I'm getting this same issue on 2.0.4. I haven't yet upgraded to 2.0.5 but will give it a shot.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1005