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 when sorting dcim interface-connections by device_b #3112

Closed
candlerb opened this issue Apr 26, 2019 · 0 comments
Closed

Exception when sorting dcim interface-connections by device_b #3112

candlerb opened this issue Apr 26, 2019 · 0 comments
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@candlerb
Copy link
Contributor

candlerb commented Apr 26, 2019

Environment

  • Python version: 3.5.2
  • NetBox version: 2.5.10

Steps to Reproduce

  1. Browse to Device -> Interface Connections (/dcim/interface-connections/)
  2. Click on the headline for Device B (i.e. sort according to Device B)
  3. This takes you to /dcim/interface-connections/?sort=device_b which raises an exception
  4. Similar exceptions are also raised for ?sort=interface_b and ?sort=description_b

Expected Behavior

Render table of connections sorted by the given parameter

Observed Behavior

Raises 'django.core.exceptions.FieldError'

image

Internal Server Error: /dcim/interface-connections/

FieldError at /dcim/interface-connections/
Cannot resolve keyword 'connected_endpoint' into field. Choices are: _cabled_as_a, _cabled_as_b, _channel, _connected_circuittermination, _connected_circuittermination_id, _connected_interface, _connected_interface_id, _id, _position, _slot, _subposition, _subslot, _type, _vc, cable, cable_id, connection_status, description, device, device_id, enabled, form_factor, id, ip_addresses, lag, lag_id, mac_address, member_interfaces, mgmt_only, mode, mtu, name, tagged_items, tagged_vlans, tags, untagged_vlan, untagged_vlan_id, virtual_machine, virtual_machine_id

Request Method: GET
Request URL: http://netbox.example.net/dcim/interface-connections/?sort=device_b
Django Version: 2.1.8
Python Executable: /usr/bin/python3
Python Version: 3.5.2
Python Path: ['/opt/netbox/netbox', '/usr/local/bin', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']
Server time: Fri, 26 Apr 2019 06:32:38 +0000
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'corsheaders',
 'debug_toolbar',
 'django_filters',
 'django_tables2',
 'mptt',
 'rest_framework',
 'taggit',
 'taggit_serializer',
 'timezone_field',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'secrets',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'drf_yasg']
Installed Middleware:
('debug_toolbar.middleware.DebugToolbarMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 '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',
 'utilities.middleware.ExceptionHandlingMiddleware',
 'utilities.middleware.LoginRequiredMiddleware',
 'utilities.middleware.APIVersionMiddleware',
 'extras.middleware.ObjectChangeMiddleware')


Traceback:

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
  126.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
  124.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/opt/netbox/netbox/utilities/views.py" in get
  180.         return render(request, self.template_name, context)

File "/usr/local/lib/python3.5/dist-packages/django/shortcuts.py" in render
  36.     content = loader.render_to_string(template_name, context, request, using=using)

File "/usr/local/lib/python3.5/dist-packages/django/template/loader.py" in render_to_string
  62.     return template.render(context, request)

File "/usr/local/lib/python3.5/dist-packages/django/template/backends/django.py" in render
  61.             return self.template.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render
  171.                     return self._render(context)

File "/usr/local/lib/python3.5/dist-packages/django/test/utils.py" in instrumented_test_render
  96.     return self.nodelist.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/loader_tags.py" in render
  150.             return compiled_parent._render(context)

File "/usr/local/lib/python3.5/dist-packages/django/test/utils.py" in instrumented_test_render
  96.     return self.nodelist.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/loader_tags.py" in render
  62.                 result = block.nodelist.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/loader_tags.py" in render
  188.             return template.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render
  173.                 return self._render(context)

File "/usr/local/lib/python3.5/dist-packages/django/test/utils.py" in instrumented_test_render
  96.     return self.nodelist.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/usr/local/lib/python3.5/dist-packages/django_tables2/templatetags/django_tables2.py" in render
  170.             return template.render(context={"table": table}, request=request)

File "/usr/local/lib/python3.5/dist-packages/django/template/backends/django.py" in render
  61.             return self.template.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render
  171.                     return self._render(context)

File "/usr/local/lib/python3.5/dist-packages/django/test/utils.py" in instrumented_test_render
  96.     return self.nodelist.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/defaulttags.py" in render
  161.             values = self.sequence.resolve(context, ignore_failures=True)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in resolve
  698.                 new_obj = func(obj, *arg_vals)

File "/usr/local/lib/python3.5/dist-packages/django/template/defaultfilters.py" in default
  754.     return value or arg

File "/usr/local/lib/python3.5/dist-packages/django_tables2/rows.py" in __len__
  335.         length = len(self.data)

File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py" in __len__
  250.         self._fetch_all()

File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py" in _fetch_all
  1186.             self._result_cache = list(self._iterable_class(self))

File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py" in __iter__
  54.         results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)

File "/usr/local/lib/python3.5/dist-packages/django/db/models/sql/compiler.py" in execute_sql
  1052.             sql, params = self.as_sql()

File "/usr/local/lib/python3.5/dist-packages/django/db/models/sql/compiler.py" in as_sql
  449.             extra_select, order_by, group_by = self.pre_sql_setup()

File "/usr/local/lib/python3.5/dist-packages/django/db/models/sql/compiler.py" in pre_sql_setup
  51.         order_by = self.get_order_by()

File "/usr/local/lib/python3.5/dist-packages/django/db/models/sql/compiler.py" in get_order_by
  315.                     field, self.query.get_meta(), default_order=asc))

File "/usr/local/lib/python3.5/dist-packages/django/db/models/sql/compiler.py" in find_ordering_name
  668.         field, targets, alias, joins, path, opts, transform_function = self._setup_joins(pieces, opts, alias)

File "/usr/local/lib/python3.5/dist-packages/django/db/models/sql/compiler.py" in _setup_joins
  698.         field, targets, opts, joins, path, transform_function = self.query.setup_joins(pieces, opts, alias)

File "/usr/local/lib/python3.5/dist-packages/django/db/models/sql/query.py" in setup_joins
  1473.                     names[:pivot], opts, allow_many, fail_on_missing=True,

File "/usr/local/lib/python3.5/dist-packages/django/db/models/sql/query.py" in names_to_path
  1389.                                      "Choices are: %s" % (name, ", ".join(available)))

Exception Type: FieldError at /dcim/interface-connections/
Exception Value: Cannot resolve keyword 'connected_endpoint' into field. Choices are: _cabled_as_a, _cabled_as_b, _channel, _connected_circuittermination, _connected_circuittermination_id, _connected_interface, _connected_interface_id, _id, _position, _slot, _subposition, _subslot, _type, _vc, cable, cable_id, connection_status, description, device, device_id, enabled, form_factor, id, ip_addresses, lag, lag_id, mac_address, member_interfaces, mgmt_only, mode, mtu, name, tagged_items, tagged_vlans, tags, untagged_vlan, untagged_vlan_id, virtual_machine, virtual_machine_id
Request information:
USER: admin

GET:
sort = 'device_b'

POST: No POST data

FILES: No FILES data

I note that the only Netbox file in that backtrace is /opt/netbox/netbox/utilities/views.py

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application labels Apr 26, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 16, 2020
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 type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants