Unable to update the site #11953

Open
opened 2025-12-29 21:51:51 +01:00 by adam · 2 comments
Owner

Originally created by @xtprox on GitHub (Dec 29, 2025).

NetBox Edition

NetBox Community

NetBox Version

v4.4.9

Python Version

3.12

Steps to Reproduce

  1. Create a new Site. You can fill only the Name field: TEST-SITE.
  2. Create a new Prefix, for instance 10.99.0.0/24, and assign it to the Scope: Site, Site: TEST-SITE
  3. Get back to the Sites list, click on TEST-SITE and press "Edit" button
  4. Without any changes press "Save" button

API call to /api/dcim/sites/ with PATCH method raises an error with code 500:

{
  "error": "Cannot use None as a query value",
  "exception": "ValueError",
  "netbox_version": "4.4.9",
  "python_version": "3.12.3"
}

Expected Behavior

Site updated successfully.

Observed Behavior

<class 'ValueError'>

Cannot use None as a query value

Python version: 3.12.3
NetBox version: 4.4.9
Plugins: None installed


Internal Server Error: /dcim/sites/491/edit/

ValueError at /dcim/sites/491/edit/
Cannot use None as a query value

Request Method: POST
Request URL: https://netbox.local/dcim/sites/491/edit/
Django Version: 5.2.9
Python Executable: /opt/netbox/venv/bin/python3 Python Version: 3.12.3 Python Path: ['/opt/netbox/netbox', '/opt/netbox', '/opt/netbox/venv/bin', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/opt/netbox/venv/lib/python3.12/site-packages']
Server time: Mon, 29 Dec 2025 16:00:39 +0200 Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'django.forms',
 'corsheaders',
 'django_filters',
 'django_htmx',
 'django_tables2',
 'django_prometheus',
 'strawberry_django',
 'mptt',
 'rest_framework',
 'social_django',
 'sorl.thumbnail',
 'taggit',
 'timezone_field',
 'core',
 'account',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'vpn',
 'wireless',
 'django_rq',
 'drf_spectacular',
 'drf_spectacular_sidecar']
Installed Middleware:
['corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 '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',
 'django_htmx.middleware.HtmxMiddleware',
 'netbox.middleware.RemoteUserMiddleware',
 'netbox.middleware.CoreMiddleware',
 'netbox.middleware.MaintenanceModeMiddleware']


Traceback (most recent call last):
  File "/opt/netbox/netbox/netbox/middleware.py", line 128, in __call__
    username = request.META[self.header]
               ^^^^^^^^^^^^^^^^^^^^^^^^^

During handling of the above exception ('HTTP_REMOTE_USER'), another exception occurred:
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 105, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 190, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/utilities/views.py", line 144, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/utilities/views.py", line 45, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 144, in dispatch
    return handler(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 297, in post
    obj = form.save()
          ^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/forms/models.py", line 554, in save
    self.instance.save()
    ^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/netbox/models/features.py", line 324, in save
    super().save(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 902, in save
    self.save_base(
    ^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 1023, in save_base
    post_save.send(
    ^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/dispatch/dispatcher.py", line 189, in send
    response = receiver(signal=self, sender=sender, **named)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/dcim/signals.py", line 216, in sync_cached_scope_fields
    obj.save(update_fields=[
    ^^
  File "/opt/netbox/netbox/ipam/models/ip.py", line 336, in save
    super().save(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/dcim/models/mixins.py", line 102, in save
    super().save(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/netbox/models/features.py", line 324, in save
    super().save(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 902, in save
    self.save_base(
    ^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 1023, in save_base
    post_save.send(
    ^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/dispatch/dispatcher.py", line 189, in send
    response = receiver(signal=self, sender=sender, **named)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/ipam/signals.py", line 41, in handle_prefix_saved
    update_parents_children(old_prefix)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/ipam/signals.py", line 13, in update_parents_children
    parents = prefix.get_parents(include_self=True).annotate_hierarchy()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/ipam/models/ip.py", line 376, in get_parents
    return Prefix.objects.filter(**{
           
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 1495, in filter
    return self._filter_or_exclude(False, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 1513, in _filter_or_exclude
    clone._filter_or_exclude_inplace(negate, args, kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 1523, in _filter_or_exclude_inplace
    self._query.add_q(Q(*args, **kwargs))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1646, in add_q
    clause, _ = self._add_q(q_object, can_reuse)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1678, in _add_q
    child_clause, needed_inner = self.build_filter(
                                 
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1588, in build_filter
    condition = self.build_lookup(lookups, col, value)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1420, in build_lookup
    raise ValueError("Cannot use None as a query value")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Exception Type: ValueError at /dcim/sites/491/edit/ Exception Value: Cannot use None as a query value Raised during: dcim.views.SiteEditView Request information:
USER: user

GET: No GET data

POST:
csrfmiddlewaretoken = '<trimmed>'
_init_time = '1767016738.9228277'
name = 'SITE-A'
slug = 'site-a'
status = 'active'
region = '3'
group = '2'
facility = ''
asns = '41'
time_zone = 'Europe/Kiev'
description = 'Some description'
tenant_group = ''
tenant = '1'
physical_address = 'Addr line'
shipping_address = ''
latitude = '123.280350'
longitude = '012.273840'
comments = ''
changelog_message = ''
_update = ''

Originally created by @xtprox on GitHub (Dec 29, 2025). ### NetBox Edition NetBox Community ### NetBox Version v4.4.9 ### Python Version 3.12 ### Steps to Reproduce 1. Create a new Site. You can fill only the Name field: TEST-SITE. 2. Create a new Prefix, for instance 10.99.0.0/24, and assign it to the Scope: Site, Site: TEST-SITE 3. Get back to the Sites list, click on TEST-SITE and press "Edit" button 4. Without any changes press "Save" button API call to `/api/dcim/sites/` with PATCH method raises an error with code 500: ``` { "error": "Cannot use None as a query value", "exception": "ValueError", "netbox_version": "4.4.9", "python_version": "3.12.3" } ``` ### Expected Behavior Site updated successfully. ### Observed Behavior ``` <class 'ValueError'> Cannot use None as a query value Python version: 3.12.3 NetBox version: 4.4.9 Plugins: None installed ``` --- ``` Internal Server Error: /dcim/sites/491/edit/ ValueError at /dcim/sites/491/edit/ Cannot use None as a query value Request Method: POST Request URL: https://netbox.local/dcim/sites/491/edit/ Django Version: 5.2.9 Python Executable: /opt/netbox/venv/bin/python3 Python Version: 3.12.3 Python Path: ['/opt/netbox/netbox', '/opt/netbox', '/opt/netbox/venv/bin', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/opt/netbox/venv/lib/python3.12/site-packages'] Server time: Mon, 29 Dec 2025 16:00:39 +0200 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'django.forms', 'corsheaders', 'django_filters', 'django_htmx', 'django_tables2', 'django_prometheus', 'strawberry_django', 'mptt', 'rest_framework', 'social_django', 'sorl.thumbnail', 'taggit', 'timezone_field', 'core', 'account', 'circuits', 'dcim', 'ipam', 'extras', 'tenancy', 'users', 'utilities', 'virtualization', 'vpn', 'wireless', 'django_rq', 'drf_spectacular', 'drf_spectacular_sidecar'] Installed Middleware: ['corsheaders.middleware.CorsMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', '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', 'django_htmx.middleware.HtmxMiddleware', 'netbox.middleware.RemoteUserMiddleware', 'netbox.middleware.CoreMiddleware', 'netbox.middleware.MaintenanceModeMiddleware'] Traceback (most recent call last): File "/opt/netbox/netbox/netbox/middleware.py", line 128, in __call__ username = request.META[self.header] ^^^^^^^^^^^^^^^^^^^^^^^^^ During handling of the above exception ('HTTP_REMOTE_USER'), another exception occurred: File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 105, in view return self.dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 190, in dispatch return super().dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch return super().dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/utilities/views.py", line 144, in dispatch return super().dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/utilities/views.py", line 45, in dispatch return super().dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 144, in dispatch return handler(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 297, in post obj = form.save() ^^^^^^^^^^^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/forms/models.py", line 554, in save self.instance.save() ^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/netbox/models/features.py", line 324, in save super().save(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 902, in save self.save_base( ^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 1023, in save_base post_save.send( ^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/dispatch/dispatcher.py", line 189, in send response = receiver(signal=self, sender=sender, **named) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/dcim/signals.py", line 216, in sync_cached_scope_fields obj.save(update_fields=[ ^^ File "/opt/netbox/netbox/ipam/models/ip.py", line 336, in save super().save(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/dcim/models/mixins.py", line 102, in save super().save(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/netbox/models/features.py", line 324, in save super().save(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 902, in save self.save_base( ^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 1023, in save_base post_save.send( ^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/dispatch/dispatcher.py", line 189, in send response = receiver(signal=self, sender=sender, **named) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/ipam/signals.py", line 41, in handle_prefix_saved update_parents_children(old_prefix) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/ipam/signals.py", line 13, in update_parents_children parents = prefix.get_parents(include_self=True).annotate_hierarchy() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/ipam/models/ip.py", line 376, in get_parents return Prefix.objects.filter(**{ File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 1495, in filter return self._filter_or_exclude(False, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 1513, in _filter_or_exclude clone._filter_or_exclude_inplace(negate, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 1523, in _filter_or_exclude_inplace self._query.add_q(Q(*args, **kwargs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1646, in add_q clause, _ = self._add_q(q_object, can_reuse) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1678, in _add_q child_clause, needed_inner = self.build_filter( File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1588, in build_filter condition = self.build_lookup(lookups, col, value) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1420, in build_lookup raise ValueError("Cannot use None as a query value") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Exception Type: ValueError at /dcim/sites/491/edit/ Exception Value: Cannot use None as a query value Raised during: dcim.views.SiteEditView Request information: USER: user GET: No GET data POST: csrfmiddlewaretoken = '<trimmed>' _init_time = '1767016738.9228277' name = 'SITE-A' slug = 'site-a' status = 'active' region = '3' group = '2' facility = '' asns = '41' time_zone = 'Europe/Kiev' description = 'Some description' tenant_group = '' tenant = '1' physical_address = 'Addr line' shipping_address = '' latitude = '123.280350' longitude = '012.273840' comments = '' changelog_message = '' _update = '' ```
adam added the type: bugstatus: revisions needednetbox labels 2025-12-29 21:51:51 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 29, 2025):

Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.

@jeremystretch commented on GitHub (Dec 29, 2025): Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.
Author
Owner

@xtprox commented on GitHub (Dec 29, 2025):

Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.

I've updated steps to reproduce.

@xtprox commented on GitHub (Dec 29, 2025): > Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports. I've updated steps to reproduce.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11953