netbox-community / netbox-topology-views

A netbox plugin that draws topology views
Apache License 2.0
731 stars 63 forks source link

get() returned more than one RoleImage -- it returned 2! #526

Closed mumaritc closed 3 weeks ago

mumaritc commented 1 month ago

NetBox version

v4.0.7

Topology Views version

v4.0.0

Steps to Reproduce

  1. Set the images for default device types
  2. Now clicking Topology shows server error

Expected Behavior

Show the Topology view

Observed Behavior

Server Error shows up: <class 'netbox_topology_views.models.RoleImage.MultipleObjectsReturned'>

get() returned more than one RoleImage -- it returned 2!

Python version: 3.10.12 NetBox version: 4.0.7 Plugins: netbox_topology_views: 4.0.0

Images are not duplicate as shown image

mattieserver commented 1 month ago

Can you play with the filters and see what role causes the issue?

mumaritc commented 1 month ago

Filter for Show Unconnected devices is causing the issue, unchecking it will open the topology views, but no devices or view is showing

NotHBlocks commented 1 month ago

Can you play with the filters and see what role causes the issue?

I´ve got the same bug. I changed the Role images and can´t open the Topology view. I removed all filters and the topology view will open now but don´t show anything.

I also can´t change the picture again. If I click the button an error message will appear:

Error Message Netbox

If I activate some filters this error Message will appear by opening the topology view:

image

The console in my browser display this error message:

image

I hope this will help to fix the error.

dreng commented 1 month ago

Thanks for your report. Can anyone of you show the content of the table 'netbox_topology_views_roleimage'?

You can use dbshell for this task:

  1. Activate your venv: source "path_to_your_venv_folder/bin/activate
  2. python "path_to_your_netbox_folder"/netbox/manage.py dbshell
  3. select * from netbox_topology_views_roleimage;
NotHBlocks commented 1 month ago

3. select * from netbox_topology_views_roleimage;

Hello deng,

of course. I´ve did a screenshot.

image

My guess is that I have to delete the double entries right? But why were they created multiple times? is that a bug?

mumaritc commented 1 month ago

Hello deng,

  1. select * from netbox_topology_views_roleimage; content

image

dreng commented 4 weeks ago

The numbers in column "object_id" should be unique. It is save to delete any rows in that table. Just use dbshell:

delete from netbox_topology_views_roleimage where object_id = OBJECT_ID_TO_BE_DELETED;

I don't know what caused this situation. The object_id belongs to the role id. Have you deleted one or more roles and added new roles after that?

NotHBlocks commented 4 weeks ago

The numbers in column "object_id" should be unique. It is save to delete any rows in that table. Just use dbshell:

delete from netbox_topology_views_roleimage where object_id = OBJECT_ID_TO_BE_DELETED;

I changed your command a bit. I used: delete from netbox_topology_views_roleimage where id = ID_TO_BE_DELETED;

with this command I can just delete the duplicates and I don´t need to save the images again (Reduce the risk to run again in this bug).

I don't know what caused this situation. The object_id belongs to the role id. Have you deleted one or more roles and added new roles after that?

I dind´t changed anything at the role names. I just selected the images for the roles, hit the save button and after that the error Message occured. It was a bit strange but now I know how to fix this issue. Thank you a lot.

dreng commented 4 weeks ago

I played around a bit and I couldn't reproduce such a situation. I created new roles, assigned images, deleted some roles... the table was always in a correct state.

@mumaritc Have you got any hints what may have caused this situation?