netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
16.16k stars 2.59k forks source link

Server Error after modifying permission contstraints #16854

Closed lono0778 closed 3 months ago

lono0778 commented 4 months ago

Deployment Type

NetBox Cloud

NetBox Version

v4.0.6

Python Version

3.10

Steps to Reproduce

open user permission and add sth. to constraints, e.g. {"status": "active"} and click save

Expected Behavior

it should result in a error message below the constraints field: Invalid filter for <class 'circuits.models.circuits.CircuitTermination'>: Cannot resolve keyword 'status' into field. Choices are: cable, cable_end, cable_id, cable_terminations, circuit, circuit_id, created, custom_field_data, description, id, last_updated, mark_connected, port_speed, pp_info, provider_network, provider_network_id, site, site_id, tagged_items, tags, term_side, upstream_speed, xconnect_id

Observed Behavior

Server Error

There was a problem with your request. Please contact an administrator.

The complete exception is provided below:

<class 'AttributeError'>

'NoneType' object has no attribute 'objects'

Python version: 3.10.12 NetBox version: 4.0.6 Plugins: netbox_dns: 1.0.4 netbox_documents: 0.7.0 netbox_floorplan: 0.4.0 netbox_qrcode: 0.0.13

If further assistance is required, please post to the NetBox discussion forum on GitHub.

Debug output:

Environment:

Request Method: POST Request URL: https://demo.nb.dc-smarter.int/users/permissions/12/edit/?return_url=/users/permissions/

Django Version: 5.0.6 Python Version: 3.10.12 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'django.forms', 'corsheaders', 'debug_toolbar', 'django_filters', 'django_htmx', 'django_tables2', 'django_prometheus', 'strawberry_django', 'mptt', 'rest_framework', 'social_django', 'taggit', 'timezone_field', 'core', 'account', 'circuits', 'dcim', 'ipam', 'extras', 'tenancy', 'users', 'utilities', 'virtualization', 'vpn', 'wireless', 'django_rq', 'drf_spectacular', 'drf_spectacular_sidecar', 'netbox_floorplan.FloorplanConfig', 'netbox_documents.NetboxDocuments', 'netbox_dns.DNSConfig', 'netbox_qrcode.QRCodeConfig'] Installed Middleware: ['strawberry_django.middlewares.debug_toolbar.DebugToolbarMiddleware', '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/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/opt/netbox/venv/lib/python3.10/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.10/site-packages/django/views/generic/base.py", line 104, in view return self.dispatch(request, *args, *kwargs) File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 177, 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 113, in dispatch return super().dispatch(request, *args, *kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch return handler(request, args, kwargs) File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 265, in post if form.is_valid(): File "/opt/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py", line 197, in is_valid return self.is_bound and not self.errors File "/opt/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py", line 192, in errors self.full_clean() File "/opt/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py", line 328, in full_clean self._clean_form() File "/opt/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py", line 349, in _clean_form cleaned_data = self.clean() File "/opt/netbox/netbox/users/forms/model_forms.py", line 376, in clean model.objects.filter(qs_filter_from_constraints(constraints, tokens)).exists()

Exception Type: AttributeError at /users/permissions/12/edit/ Exception Value: 'NoneType' object has no attribute 'objects'

DanSheps commented 4 months ago

Steps to Reproduce

Please be more detailed. What page do I navigate to, to get this error? What permission is being created specifically? What models are selected.

lono0778 commented 3 months ago

Hi Dan, grafik

Hi Dan, sorry, i found the issue which was caused by formerly installed axians pdu plugin. By deselecting those 2, all works as expected.