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

FieldError exception raised in 3.2beta (docker image from 3/9/2022) #8838

Closed
jcollie opened this issue Mar 9, 2022 · 2 comments
Closed

FieldError exception raised in 3.2beta (docker image from 3/9/2022) #8838

jcollie opened this issue Mar 9, 2022 · 2 comments
Assignees
Labels
beta Concerns a bug/feature in a beta release status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@jcollie
Copy link

jcollie commented Mar 9, 2022

NetBox version

netbox-7f458459b6-pq69t (v3.2.0-beta1) (docker image from 3/9/2022)

Python version

3.9

Steps to Reproduce

  1. Type some text into global search field.
  2. Click on search button.

Expected Behavior

Should bring up a search for the entered string.

Observed Behavior

FieldError exception raised.

Environment:


Request Method: GET
Request URL: https://netbox.dmacc.net/search/?q=34295&obj_type=

Django Version: 4.0.2
Python Version: 3.9.5
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',
 'graphiql_debug_toolbar',
 'django_filters',
 'django_tables2',
 'django_prometheus',
 'graphene_django',
 'mptt',
 'rest_framework',
 'social_django',
 'taggit',
 'timezone_field',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'wireless',
 'django_rq',
 'drf_yasg']
Installed Middleware:
['graphiql_debug_toolbar.middleware.DebugToolbarMiddleware',
 'django_prometheus.middleware.PrometheusBeforeMiddleware',
 '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',
 'netbox.middleware.ExceptionHandlingMiddleware',
 'netbox.middleware.RemoteUserMiddleware',
 'netbox.middleware.LoginRequiredMiddleware',
 'netbox.middleware.DynamicConfigMiddleware',
 'netbox.middleware.APIVersionMiddleware',
 'netbox.middleware.ObjectChangeMiddleware',
 'django_prometheus.middleware.PrometheusAfterMiddleware']



Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 101, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/__init__.py", line 181, in get
    filtered_queryset = filterset({'q': form.cleaned_data['q']}, queryset=queryset).qs
  File "/opt/netbox/venv/lib/python3.9/site-packages/django_filters/filterset.py", line 243, in qs
    qs = self.filter_queryset(qs)
  File "/opt/netbox/venv/lib/python3.9/site-packages/django_filters/filterset.py", line 230, in filter_queryset
    queryset = self.filters[name].filter(queryset, value)
  File "/opt/netbox/venv/lib/python3.9/site-packages/django_filters/filters.py", line 779, in __call__
    return self.method(qs, self.f.field_name, value)
  File "/opt/netbox/netbox/dcim/filtersets.py", line 171, in search
    return queryset.filter(qs_filter)
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/query.py", line 974, in filter
    return self._filter_or_exclude(False, args, kwargs)
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/query.py", line 992, in _filter_or_exclude
    clone._filter_or_exclude_inplace(negate, args, kwargs)
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/query.py", line 999, in _filter_or_exclude_inplace
    self._query.add_q(Q(*args, **kwargs))
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1375, in add_q
    clause, _ = self._add_q(q_object, self.used_aliases)
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1396, in _add_q
    child_clause, needed_inner = self.build_filter(
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1252, in build_filter
    return self._add_q(
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1396, in _add_q
    child_clause, needed_inner = self.build_filter(
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1271, in build_filter
    lookups, parts, reffed_expression = self.solve_lookup_type(arg)
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1099, in solve_lookup_type
    _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1522, in names_to_path
    raise FieldError("Cannot resolve keyword '%s' into field. "

Exception Type: FieldError at /search/
Exception Value: Cannot resolve keyword 'asn' into field. Choices are: _name, asns, circuit_terminations, clusters, comments, contacts, created, custom_field_data, description, devices, facility, group, group_id, id, images, journal_entries, last_updated, latitude, locations, longitude, name, physical_address, powerpanel, prefixes, racks, region, region_id, shipping_address, slug, status, tagged_items, tags, tenant, tenant_id, time_zone, vlan_groups, vlans
@jcollie jcollie added the type: bug A confirmed report of unexpected behavior in the application label Mar 9, 2022
@jcollie
Copy link
Author

jcollie commented Mar 9, 2022

Clarifying that this only happens when searching for "All Objects". Searching for just devices works just fine.

@raschkeb
Copy link

It can be easily reproduced with the beta-demo site:

https://beta-demo.netbox.dev/search/?q=42&obj_type=

leads to:
<class 'django.core.exceptions.FieldError'>

Cannot resolve keyword 'asn' into field. Choices are: _name, asns, circuit_terminations, clusters, comments, contacts, created, custom_field_data, description, devices, facility, group, group_id, id, images, journal_entries, last_updated, latitude, locations, longitude, name, physical_address, powerpanel, prefixes, racks, region, region_id, shipping_address, slug, status, tagged_items, tags, tenant, tenant_id, time_zone, vlan_groups, vlans

Python version: 3.8.10
NetBox version: 3.2.0-beta2

But only for integer numbers. Text entered in the search field leads to the expected results.

@jeremystretch jeremystretch added beta Concerns a bug/feature in a beta release status: accepted This issue has been accepted for implementation labels Mar 10, 2022
@jeremystretch jeremystretch self-assigned this Mar 14, 2022
This was referenced Apr 5, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beta Concerns a bug/feature in a beta release 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

3 participants