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

v0.5.0 version does not work: various occurrences of "ReferenceError" in dev console #63

Open
litebito opened this issue Dec 9, 2024 · 2 comments
Assignees

Comments

@litebito
Copy link

litebito commented Dec 9, 2024

Hi,

I'm running:

  • Netbox 4.1.7
  • netbox-floorplan-plugin 0.5.0

No errors during installation, but the plugin does not work.
In a location, I can go to the tab "Floorplan" but when I click on "edit floorplan"
I get the following in the netbox_debug log:

Exception while resolving variable 'name' in template 'netbox_floorplan/floorplan_edit.html'.
Traceback (most recent call last):
  File "/opt/netbox/venv/lib64/python3.12/site-packages/django/template/base.py", line 875, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
TypeError: 'Floorplan' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib64/python3.12/site-packages/django/template/base.py", line 885, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Floorplan' object has no attribute 'name'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib64/python3.12/site-packages/django/template/base.py", line 891, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'name'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib64/python3.12/site-packages/django/template/base.py", line 898, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [name] in <Floorplan: BTB01 Floorplan>
Exception while resolving variable 'id' in template 'netbox_floorplan/floorplan_edit.html'.
Traceback (most recent call last):
  File "/opt/netbox/venv/lib64/python3.12/site-packages/django/template/base.py", line 875, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib64/python3.12/site-packages/django/template/base.py", line 885, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib64/python3.12/site-packages/django/template/base.py", line 891, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib64/python3.12/site-packages/django/template/base.py", line 898, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [id] in None

It continues in edit mode, but if I then try to click buttons like "Set Dimensions" or "Set/Edit Background"
nothing happens in de netbox_debug log, but in the browser dev console, I see following errors:

Uncaught ReferenceError: fabric is not defined
    at view.js:12:14
edit.js:26  Uncaught ReferenceError: htmx is not defined
    at edit.js:26:1
edit/:1  Uncaught ReferenceError: set_dimensions is not defined
    at HTMLAnchorElement.onclick (edit/:1:1)
edit/:1  Uncaught ReferenceError: set_background is not defined
    at HTMLAnchorElement.onclick (edit/:1:1)

I already tried to:
1/ check if the files are there: yes:

# ls -l /opt/netbox/netbox/static/netbox_floorplan/floorplan/
total 44
-rw-r--r--. 1 root root 26287 Dec  9 15:03 edit.js
-rw-r--r--. 1 root root  8390 Dec  9 15:03 utils.js
-rw-r--r--. 1 root root  1515 Dec  9 15:03 view.js
# ls -l /opt/netbox/netbox/static/netbox_floorplan/vendors/
total 444
-rw-r--r--. 1 root root 312284 Dec  9 15:03 fabric-js-6.0.2.js
-rw-r--r--. 1 root root  48101 Dec  9 15:03 htmx.min.js
-rw-r--r--. 1 root root  87533 Dec  9 15:03 jquery-3.7.1.js

2/ redo the migrations & collect static
(no errors)

How can we fix this?

@cruse1977
Copy link
Member

cruse1977 commented Dec 9, 2024

Hi, I've not seen this error in development and I've been unable to replicate this in docker - however you haven't included much information and 2/ confuses this.

The errors look like Javascript isn't being loaded

  • new install or upgrade
  • are you stating you need to run collectstatic twice and this resolves this ?
  • what does the network tab say in dev tools - ie: is the javascript being loaded and 200 status code on the files ?
  • if not 200, what do the ingress/nginx/webserver logs say
  • is netbox using the default base path (ie: has not been moved moved to a subdirectory)

@cruse1977 cruse1977 self-assigned this Dec 9, 2024
@cruse1977 cruse1977 added revisions-needed question Further information is requested not-reproducable and removed question Further information is requested not-reproducable labels Dec 9, 2024
@litebito
Copy link
Author

litebito commented Dec 9, 2024

Hi,

to answer your questions:

  • it is about adding the floorplanplugin to an existing Netbox installation
  • no, I ran collect static, and I ran migrations, as this fixed a similar issue in other posts here, but that did not fix the issue
  • netbox is using the default basepath
  • in the webserver logs, I don't see any errors:
10.226.34.85 - - [10/Dec/2024:12:47:32 +0100] "GET /dcim/locations/ HTTP/1.1" 200 341095 "https://[SERVERFQDN]/dcim/devices/445/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
10.226.34.85 - - [10/Dec/2024:12:47:35 +0100] "GET /dcim/locations/29/ HTTP/1.1" 200 144798 "https://[SERVERFQDN]/dcim/locations/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
10.226.34.85 - - [10/Dec/2024:12:47:36 +0100] "GET /extras/image-attachments/?embedded=True&object_type_id=41&object_id=29&return_url=%2Fdcim%2Flocations%2F29%2F HTTP/1.1" 200 2671 "https://[SERVERFQDN]/dcim/locations/29/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
10.226.34.85 - - [10/Dec/2024:12:47:36 +0100] "GET /dcim/locations/?embedded=True&parent_id=29&return_url=%2Fdcim%2Flocations%2F29%2F HTTP/1.1" 200 3910 "https://[SERVERFQDN]/dcim/locations/29/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
10.226.34.85 - - [10/Dec/2024:12:47:36 +0100] "GET /dcim/devices/?embedded=True&location_id=29&rack_id=null&parent_bay_id=null&return_url=%2Fdcim%2Flocations%2F29%2F HTTP/1.1" 200 5355 "https://[SERVERFQDN]/dcim/locations/29/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
10.226.34.85 - - [10/Dec/2024:12:47:36 +0100] "GET /static/Inter-SemiBoldItalic-ABO2DCC7.woff2?v=3.18 HTTP/1.1" 304 - "https://[SERVERFQDN]/static/netbox-external.css?v=4.1.7" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
10.226.34.85 - - [10/Dec/2024:12:47:38 +0100] "GET /dcim/locations/29/floorplans/ HTTP/1.1" 200 137226 "https://[SERVERFQDN]/dcim/locations/29/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
10.226.34.85 - - [10/Dec/2024:12:47:38 +0100] "GET /static/netbox_floorplan/floorplan/view.js HTTP/1.1" 304 - "https://[SERVERFQDN]/dcim/locations/29/floorplans/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
10.226.34.85 - - [10/Dec/2024:12:47:39 +0100] "GET /static/netbox_floorplan/floorplan/utils.js HTTP/1.1" 304 - "https://[SERVERFQDN]/static/netbox_floorplan/floorplan/view.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
10.226.34.85 - - [10/Dec/2024:12:47:42 +0100] "GET /plugins/floorplan/floorplans/5/edit/ HTTP/1.1" 200 145074 "https://[SERVERFQDN]/dcim/locations/29/floorplans/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
10.226.34.85 - - [10/Dec/2024:12:47:43 +0100] "GET /static/netbox_floorplan/floorplan/edit.js HTTP/1.1" 304 - "https://[SERVERFQDN]/plugins/floorplan/floorplans/5/edit/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants