Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misconfiguration in PLUGINS_CONFIG causes 500 Internal Server Error #463

Closed
poupryc opened this issue Oct 28, 2024 · 6 comments · Fixed by #464
Closed

Misconfiguration in PLUGINS_CONFIG causes 500 Internal Server Error #463

poupryc opened this issue Oct 28, 2024 · 6 comments · Fixed by #464
Assignees
Labels
bug Something isn't working

Comments

@poupryc
Copy link

poupryc commented Oct 28, 2024

Versions
NetBox Version: 4.1.4
NetBox DNS Version: 1.1.4
Python Version: 3.12.3

Describe the bug
When creating a new zone, the plugin provokes the following error with the information

<class 'TypeError'>

argument of type 'bool' is not iterable

Version Python: 3.12.3
Version NetBox: 4.1.4
Plug-ins: 
  netbox_dns: 1.1.4
  netbox_inventory: 2.1.0

by activating the logs, we obtain the following traceback

2024-10-28 14:54:59,632 django.request ERROR: Internal Server Error: /plugins/netbox-dns/zones/add/
Traceback (most recent call last):
  File "/opt/netbox-4.1.4/venv/lib/python3.12/site-packages/netbox_dns/models/zone.py", line 426, in update_soa_record
    soa_record = self.record_set.get(type=RecordTypeChoices.SOA, name=soa_name)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.1.4/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-4.1.4/venv/lib/python3.12/site-packages/django/db/models/query.py", line 649, in get
    raise self.model.DoesNotExist(
netbox_dns.models.record.Record.DoesNotExist: Record matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox-4.1.4/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.1.4/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-4.1.4/venv/lib/python3.12/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 182, 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 125, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/utilities/views.py", line 39, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.1.4/venv/lib/python3.12/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 278, in post
    obj = form.save()
          ^^^^^^^^^^^
  File "/opt/netbox-4.1.4/venv/lib/python3.12/site-packages/netbox_dns/forms/zone.py", line 121, in save
    zone = super().save(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.1.4/venv/lib/python3.12/site-packages/django/forms/models.py", line 552, in save
    self.instance.save()
  File "/opt/netbox-4.1.4/venv/lib/python3.12/site-packages/netbox_dns/models/zone.py", line 866, in save
    self.update_soa_record()
  File "/opt/netbox-4.1.4/venv/lib/python3.12/site-packages/netbox_dns/models/zone.py", line 435, in update_soa_record
    Record.objects.create(
  File "/opt/netbox-4.1.4/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-4.1.4/venv/lib/python3.12/site-packages/django/db/models/query.py", line 679, in create
    obj.save(force_insert=True, using=self.db)
  File "/opt/netbox-4.1.4/venv/lib/python3.12/site-packages/netbox_dns/models/record.py", line 844, in save
    self.full_clean()
  File "/opt/netbox-4.1.4/venv/lib/python3.12/site-packages/django/db/models/base.py", line 1536, in full_clean
    self.clean()
  File "/opt/netbox-4.1.4/venv/lib/python3.12/site-packages/netbox_dns/models/record.py", line 745, in clean
    self.validate_name(new_zone=new_zone)
  File "/opt/netbox-4.1.4/venv/lib/python3.12/site-packages/netbox_dns/models/record.py", line 584, in validate_name
    self.type
TypeError: argument of type 'bool' is not iterable

To Reproduce
Steps to reproduce the behavior:

  1. Create a new zone
  2. Click on 'create'
  3. See error

Expected result
Zone should be created or a user-friendly user should be thrown.

Actual result
No new zone is created

@peteeckel peteeckel self-assigned this Oct 28, 2024
@peteeckel peteeckel added the bug Something isn't working label Oct 28, 2024
@peteeckel
Copy link
Owner

Can you please provide a list of all parameters you used for creating the zone (defaults can be omitted)? Creating zones is a very basic operation and generally does not fail the way you describe it, so something must be special to your input that causes that error.

Do you have anything in PLUGINS_CONFIG?

@poupryc
Copy link
Author

poupryc commented Oct 28, 2024

You were right, I had a PLUGINS_CONFIG with keys that don't exist in the netbox_dns configuration, any idea why that would break everything?

Problem is solved now, thanks!

@poupryc poupryc closed this as completed Oct 28, 2024
@peteeckel
Copy link
Owner

If you can show me what you have in PLUGINS_CONFIG I can have a look at what the problem might be.

@poupryc
Copy link
Author

poupryc commented Oct 28, 2024

PLUGINS_CONFIG = {
  netbox_dns: {
    menu_name: "DNS",
    allow_underscores_in_hostnames: True,
    tolerate_leading_underscore_types: True
  }
}

@peteeckel
Copy link
Owner

I see ... tolerate_leading_underscore_types needs to be an array of types, not a boolean. I'll add a safeguard so that this kind of mis-configuration does not break the whole plugin.

Thanks a lot!

@peteeckel peteeckel reopened this Oct 28, 2024
@peteeckel peteeckel changed the title Can't create a new zone Misconfiguration in PLUGINS_CONFIG causes 500 Internal Server Error Oct 28, 2024
@poupryc
Copy link
Author

poupryc commented Oct 28, 2024

Thanks for your reactivity, as always!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants