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

AttributeError raised when deleting a CircuitTermination with attached cable -> interface #11416

Closed
kkthxbye-code opened this issue Jan 6, 2023 · 1 comment · Fixed by #11419
Assignees
Labels
status: accepted This issue has been accepted for implementation topic: cabling type: bug A confirmed report of unexpected behavior in the application

Comments

@kkthxbye-code
Copy link
Contributor

NetBox version

v3.4.2

Python version

3.10

Steps to Reproduce

  1. Create a Site testsite
  2. Create a manufacturer testmanu
  3. Create a device role testrole
  4. Create a device type testdevicetype
  5. Create a device testdevice with the above pre-requisites
  6. Create two interfaces inf[1-2] of any physical type
  7. Create a Provider testprovider
  8. Create a CircuitType testcircuittype
  9. Create a Circuit testcircuit wit the above requisites
  10. Create two CircuitTermination (A & Z) to site testsite on the circuit
  11. Connect end A to inf1
  12. Connect end Z to inf2
  13. Press the delete button next to the swap button on CircuitTermination A
  14. Press delete

Expected Behavior

Circuit termination is deleted

Observed Behavior

The following exception is thrown:

Traceback (most recent call last):
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/main/devel/repos/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 "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/main/devel/repos/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/main/devel/repos/netbox/netbox/utilities/views.py", line 99, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/main/devel/repos/netbox/netbox/netbox/views/generic/object_views.py", line 366, in post
    obj.delete()
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1118, in delete
    return collector.delete()
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/db/models/deletion.py", line 493, in delete
    signals.post_delete.send(
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 176, in send
    return [
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
  File "/home/main/devel/repos/netbox/netbox/circuits/signals.py", line 27, in rebuild_cablepaths
    rebuild_paths([peer_termination])
  File "/home/main/devel/repos/netbox/netbox/dcim/utils.py", line 60, in rebuild_paths
    create_cablepath(cp.origins)
  File "/home/main/devel/repos/netbox/netbox/dcim/utils.py", line 43, in create_cablepath
    cp = CablePath.from_origin(terminations)
  File "/home/main/devel/repos/netbox/netbox/dcim/models/cables.py", line 529, in from_origin
    path.append([
  File "/home/main/devel/repos/netbox/netbox/dcim/models/cables.py", line 530, in <listcomp>
    object_to_path_node(t) for t in remote_terminations
  File "/home/main/devel/repos/netbox/netbox/dcim/utils.py", line 21, in object_to_path_node
    ct = ContentType.objects.get_for_model(obj)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/contrib/contenttypes/models.py", line 41, in get_for_model
    opts = self._get_opts(model, for_concrete_model)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/contrib/contenttypes/models.py", line 28, in _get_opts
    model = model._meta.concrete_model
AttributeError: 'NoneType' object has no attribute '_meta'
Internal Server Error: /circuits/circuit-terminations/57/delete/
Traceback (most recent call last):
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/main/devel/repos/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 "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/main/devel/repos/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/main/devel/repos/netbox/netbox/utilities/views.py", line 99, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/main/devel/repos/netbox/netbox/netbox/views/generic/object_views.py", line 366, in post
    obj.delete()
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1118, in delete
    return collector.delete()
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/db/models/deletion.py", line 493, in delete
    signals.post_delete.send(
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 176, in send
    return [
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
  File "/home/main/devel/repos/netbox/netbox/circuits/signals.py", line 27, in rebuild_cablepaths
    rebuild_paths([peer_termination])
  File "/home/main/devel/repos/netbox/netbox/dcim/utils.py", line 60, in rebuild_paths
    create_cablepath(cp.origins)
  File "/home/main/devel/repos/netbox/netbox/dcim/utils.py", line 43, in create_cablepath
    cp = CablePath.from_origin(terminations)
  File "/home/main/devel/repos/netbox/netbox/dcim/models/cables.py", line 529, in from_origin
    path.append([
  File "/home/main/devel/repos/netbox/netbox/dcim/models/cables.py", line 530, in <listcomp>
    object_to_path_node(t) for t in remote_terminations
  File "/home/main/devel/repos/netbox/netbox/dcim/utils.py", line 21, in object_to_path_node
    ct = ContentType.objects.get_for_model(obj)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/contrib/contenttypes/models.py", line 41, in get_for_model
    opts = self._get_opts(model, for_concrete_model)
  File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/contrib/contenttypes/models.py", line 28, in _get_opts
    model = model._meta.concrete_model
AttributeError: 'NoneType' object has no attribute '_meta'
@kkthxbye-code kkthxbye-code added the type: bug A confirmed report of unexpected behavior in the application label Jan 6, 2023
@kkthxbye-code
Copy link
Contributor Author

The cause might be similar to #10201

Cable paths are rebuilt for a path where parts are in the process of being deleted?

@arthanson arthanson self-assigned this Jan 6, 2023
@jeremystretch jeremystretch changed the title Exception is thrown when deleting a CircuitTermination with attached cable -> interface AttributeError raised when deleting a CircuitTermination with attached cable -> interface Jan 6, 2023
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Jan 11, 2023
jeremystretch added a commit that referenced this issue Jan 12, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation topic: cabling type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants