Rack Elevation: can only concatenate str (not "int") to str #11114

Closed
opened 2025-12-29 21:40:29 +01:00 by adam · 2 comments
Owner

Originally created by @mathieumd on GitHub (May 2, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.3.0

Python Version

3.12

Steps to Reproduce

  1. Access a rack page (which loads /api/dcim/racks/4/elevation/?face=front&render=svg and /api/dcim/racks/4/elevation/?face=rear&render=svg)
  2. See that rack elevation is not displayed
  3. (Optionally, click on "Download SVG" → Get a "Server Error" served by NetBox)

Expected Behavior

Rack elevation should be displayed.

Observed Behavior

It's not. Instead, you receive a mail with:

Traceback (most recent call last):
  File "/opt/netbox-4.3.0/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.3.0/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.3.0/venv/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.3.0/venv/lib/python3.12/site-packages/rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/netbox/api/viewsets/__init__.py", line 140, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.3.0/venv/lib/python3.12/site-packages/rest_framework/views.py", line 515, in dispatch
    response = self.handle_exception(exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.3.0/venv/lib/python3.12/site-packages/rest_framework/views.py", line 475, in handle_exception
    self.raise_uncaught_exception(exc)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-4.3.0/venv/lib/python3.12/site-packages/rest_framework/views.py", line 486, in raise_uncaught_exception
    raise exc
    ^^^^^^^^^
  File "/opt/netbox-4.3.0/venv/lib/python3.12/site-packages/rest_framework/views.py", line 512, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/dcim/api/views.py", line 211, in elevation
    drawing = rack.get_elevation_svg(
              
  File "/opt/netbox/netbox/dcim/models/racks.py", line 600, in get_elevation_svg
    return elevation.render(face)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/dcim/svg/racks.py", line 332, in render
    self.drawing = self._setup_drawing()
                   ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/dcim/svg/racks.py", line 133, in _setup_drawing
    height = self.unit_height * self.rack.u_height + RACK_ELEVATION_BORDER_WIDTH * 2
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Exception Type: TypeError at /api/dcim/racks/4/elevation/
Exception Value: can only concatenate str (not "int") to str
Raised during: dcim.api.views.RackViewSet
Originally created by @mathieumd on GitHub (May 2, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.3.0 ### Python Version 3.12 ### Steps to Reproduce 1. Access a rack page (which loads `/api/dcim/racks/4/elevation/?face=front&render=svg` and `/api/dcim/racks/4/elevation/?face=rear&render=svg`) 2. See that rack elevation is not displayed 3. (Optionally, click on "Download SVG" → Get a "Server Error" served by NetBox) ### Expected Behavior Rack elevation should be displayed. ### Observed Behavior It's not. Instead, you receive a mail with: ``` Traceback (most recent call last): File "/opt/netbox-4.3.0/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox-4.3.0/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.3.0/venv/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper return view_func(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox-4.3.0/venv/lib/python3.12/site-packages/rest_framework/viewsets.py", line 125, in view return self.dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/netbox/api/viewsets/__init__.py", line 140, in dispatch return super().dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox-4.3.0/venv/lib/python3.12/site-packages/rest_framework/views.py", line 515, in dispatch response = self.handle_exception(exc) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox-4.3.0/venv/lib/python3.12/site-packages/rest_framework/views.py", line 475, in handle_exception self.raise_uncaught_exception(exc) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox-4.3.0/venv/lib/python3.12/site-packages/rest_framework/views.py", line 486, in raise_uncaught_exception raise exc ^^^^^^^^^ File "/opt/netbox-4.3.0/venv/lib/python3.12/site-packages/rest_framework/views.py", line 512, in dispatch response = handler(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/dcim/api/views.py", line 211, in elevation drawing = rack.get_elevation_svg( File "/opt/netbox/netbox/dcim/models/racks.py", line 600, in get_elevation_svg return elevation.render(face) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/dcim/svg/racks.py", line 332, in render self.drawing = self._setup_drawing() ^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/netbox/dcim/svg/racks.py", line 133, in _setup_drawing height = self.unit_height * self.rack.u_height + RACK_ELEVATION_BORDER_WIDTH * 2 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Exception Type: TypeError at /api/dcim/racks/4/elevation/ Exception Value: can only concatenate str (not "int") to str Raised during: dcim.api.views.RackViewSet ```
adam added the type: bug label 2025-12-29 21:40:29 +01:00
adam closed this issue 2025-12-29 21:40:30 +01:00
Author
Owner

@bctiemann commented on GitHub (May 2, 2025):

@mathieumd I'm not able to reproduce this, but forensically it seems like the only way this would be possible is if config.RACK_ELEVATION_DEFAULT_UNIT_HEIGHT is set to a string value, as self.unit_height is the only thing on line 133 that might potentially not be an int:

874d020d57/netbox/dcim/svg/racks.py (L93-L93)

874d020d57/netbox/dcim/svg/racks.py (L132-L133)

Could you check that your local configuration has not set RACK_ELEVATION_DEFAULT_UNIT_HEIGHT to a string?

@bctiemann commented on GitHub (May 2, 2025): @mathieumd I'm not able to reproduce this, but forensically it seems like the only way this would be possible is if `config.RACK_ELEVATION_DEFAULT_UNIT_HEIGHT` is set to a string value, as `self.unit_height` is the only thing on line 133 that might potentially not be an int: https://github.com/netbox-community/netbox/blob/874d020d574062c2965248bbdfe3cb8c44e4946e/netbox/dcim/svg/racks.py#L93-L93 https://github.com/netbox-community/netbox/blob/874d020d574062c2965248bbdfe3cb8c44e4946e/netbox/dcim/svg/racks.py#L132-L133 Could you check that your local configuration has not set `RACK_ELEVATION_DEFAULT_UNIT_HEIGHT` to a string?
Author
Owner

@mathieumd commented on GitHub (May 2, 2025):

Thank you so much @bctiemann! In /opt/netbox/netbox/netbox/configuration.py we had RACK_ELEVATION_DEFAULT_UNIT_HEIGHT = '42' (and POWERFEED_DEFAULT_VOLTAGE = '220'). I removed the single-quotes and now it's working again! Thank you, and sorry for the waste of your time...

@mathieumd commented on GitHub (May 2, 2025): Thank you so much @bctiemann! In `/opt/netbox/netbox/netbox/configuration.py` we had `RACK_ELEVATION_DEFAULT_UNIT_HEIGHT = '42'` (and `POWERFEED_DEFAULT_VOLTAGE = '220'`). I removed the single-quotes and now it's working again! Thank you, and sorry for the waste of your time...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11114