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

Exception while creating a device #16721

Closed
dteknet opened this issue Jun 25, 2024 · 4 comments
Closed

Exception while creating a device #16721

dteknet opened this issue Jun 25, 2024 · 4 comments
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@dteknet
Copy link

dteknet commented Jun 25, 2024

Deployment Type

Self-hosted

NetBox Version

v4.0.5

Python Version

3.10

Steps to Reproduce

  1. Prerequisites:
    • a site and a rack on that site
    • some random device type
    • some random device role
    • open developer tools in the browser, network tab
  2. Proceed with the nav menu to the Devices section and click on "+" to create a new device
  3. Fill the device name, select the device type, select the site, select the rack
  4. Click on the "x" icon after the rack element clearing the field
    image

Observe the network tab of devtools for failed GET request.

Expected Behavior

No exception is raised.

Observed Behavior

image

Internal Server Error: /api/dcim/racks/{{rack}}/elevation/

ValueError at /api/dcim/racks/{{rack}}/elevation/
Field 'id' expected a number but got '{{rack}}'.

Request Method: GET
Request URL: https://netbox.local/api/dcim/racks/%7B%7Brack%7D%7D/elevation/?brief=true&face=front&limit=100
Django Version: 5.0.6
Python Executable: /opt/netbox/venv/bin/python3
Python Version: 3.10.12
Python Path: ['/opt/netbox/netbox', '/opt/netbox', '/opt/netbox/venv/bin', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/opt/netbox/venv/lib/python3.10/site-packages']
Server time: Tue, 25 Jun 2024 16:11:46 +0300
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'django.forms',
 'corsheaders',
 'django_filters',
 'django_htmx',
 'django_tables2',
 'django_prometheus',
 'strawberry_django',
 'mptt',
 'rest_framework',
 'social_django',
 'taggit',
 'timezone_field',
 'core',
 'account',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'vpn',
 'wireless',
 'django_rq',
 'drf_spectacular',
 'drf_spectacular_sidecar']
Installed Middleware:
['strawberry_django.middlewares.debug_toolbar.DebugToolbarMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django_htmx.middleware.HtmxMiddleware',
 'netbox.middleware.RemoteUserMiddleware',
 'netbox.middleware.CoreMiddleware',
 'netbox.middleware.MaintenanceModeMiddleware']


Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 2117, in get_prep_value
    return int(value)

The above exception (invalid literal for int() with base 10: '{{rack}}') was the direct cause of the following exception:
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/opt/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 "/opt/netbox/venv/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
    return view_func(request, *args, **kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/viewsets.py", line 124, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/api/viewsets/__init__.py", line 135, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/dcim/api/views.py", line 184, in elevation
    rack = get_object_or_404(self.queryset, pk=pk)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/shortcuts.py", line 86, in get_object_or_404
    return queryset.get(*args, **kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 635, in get
    clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1476, in filter
    return self._filter_or_exclude(False, args, kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1494, in _filter_or_exclude
    clone._filter_or_exclude_inplace(negate, args, kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1501, in _filter_or_exclude_inplace
    self._query.add_q(Q(*args, **kwargs))
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1613, in add_q
    clause, _ = self._add_q(q_object, self.used_aliases)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1645, in _add_q
    child_clause, needed_inner = self.build_filter(
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1559, in build_filter
    condition = self.build_lookup(lookups, col, value)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1389, in build_lookup
    lookup = lookup_class(lhs, rhs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/lookups.py", line 30, in __init__
    self.rhs = self.get_prep_lookup()
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/lookups.py", line 364, in get_prep_lookup
    return super().get_prep_lookup()
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/lookups.py", line 88, in get_prep_lookup
    return self.lhs.output_field.get_prep_value(self.rhs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 2119, in get_prep_value
    raise e.__class__(

Exception Type: ValueError at /api/dcim/racks/{{rack}}/elevation/
Exception Value: Field 'id' expected a number but got '{{rack}}'.
Raised during: dcim.api.views.RackViewSet
Request information:
USER: admin

GET:
brief = 'true'
face = 'front'
limit = '100'

POST: No POST data

FILES: No FILES data
@dteknet dteknet added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Jun 25, 2024
@arthanson arthanson added status: revisions needed This issue requires additional information to be actionable and removed status: needs triage This issue is awaiting triage by a maintainer labels Jun 25, 2024
@arthanson
Copy link
Collaborator

Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v4.0.5. Please re-confirm the reported behavior on the current stable release and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. Remember to include the steps taken to create any initial objects or other data.

@dteknet
Copy link
Author

dteknet commented Jun 26, 2024

Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v4.0.5. Please re-confirm the reported behavior on the current stable release and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. Remember to include the steps taken to create any initial objects or other data.

Hi Arthur,
I forgot to mention that you need to look for it in the browser dev tools, network tab. As an administrator, I'm receiving an e-mail each time someone triggers the issue. There's no visible exception in the browser other than a failed GET request which you can find in the network tab. I was able to reproduce the same error on the demo site (demo.netbox.dev).

@Kani999
Copy link

Kani999 commented Jun 26, 2024

  • Error Internal Server Error: /api/dcim/racks/{{rack}}/elevation/ also happens, when you edit a Device with assigned Rack. When you click on changing a Site (then a Rack is changed to None) I will receive an e-mail from NetBox with message:
Internal Server Error: /api/dcim/racks/{{rack}}/elevation/

ValueError at /api/dcim/racks/{{rack}}/elevation/
Field 'id' expected a number but got '{{rack}}'.
  • I suppose this error happens during API call to racks while selecting objects in the UI
  • Using NetBox v4.0.6

@SYNLINQ
Copy link

SYNLINQ commented Jul 1, 2024

Hello,

can confirm, just got the same exact issue.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: revisions needed This issue requires additional information to be actionable labels Jul 4, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

5 participants