nautobot / nautobot-app-golden-config

Golden Configuration App for Nautobot.
https://docs.nautobot.com/projects/golden-config/en/latest/
Other
101 stars 57 forks source link

SoT Agg view returning KeyError #257

Closed whitej6 closed 2 years ago

whitej6 commented 2 years ago

Environment

Steps to Reproduce

  1. Navigate to a Device Object
  2. Click on link on bottom right for SoT Aggregation Data
  3. KeyError Occurs - Appears to only be on devices without a matching scope in GC settings

Expected Behavior

Either link for devices not in scope does not appear OR is able to return an empty rendered GQL response

Observed Behavior

If a mapping does not exist for said device in GC settings it returns KeyError.

whitej6 commented 2 years ago

Traceback from demo.nautobot.com.

2022-05-12T15:14:01-06:00   [pid: 42|app: 0|req: 33244/122653] 10.23.108.53 () {64 vars in 1745 bytes} [Thu May 12 21:14:01 2022] GET /plugins/golden-config/config-compliance/details/92f22ed7-a81c-4ad9-8fd6-81874f1a32b3/sotagg/ => generated 1974 bytes in 278 msecs (HTTP/1.1 500) 7 headers in 232 bytes (1 switches on core 0)

2022-05-12T15:14:01-06:00   KeyError: UUID('92f22ed7-a81c-4ad9-8fd6-81874f1a32b3')

2022-05-12T15:14:01-06:00       settings = get_device_to_settings_map(queryset=Device.objects.filter(pk=device.pk))[device.id]

2022-05-12T15:14:01-06:00     File "/usr/local/lib/python3.7/site-packages/nautobot_golden_config/views.py", line 396, in get

2022-05-12T15:14:01-06:00       return handler(request, *args, **kwargs)

2022-05-12T15:14:01-06:00     File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 98, in dispatch

2022-05-12T15:14:01-06:00       return super().dispatch(request, *args, **kwargs)

2022-05-12T15:14:01-06:00     File "/usr/local/lib/python3.7/site-packages/nautobot/utilities/views.py", line 48, in dispatch

2022-05-12T15:14:01-06:00       return self.dispatch(request, *args, **kwargs)

2022-05-12T15:14:01-06:00     File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 70, in view

2022-05-12T15:14:01-06:00       response = wrapped_callback(request, *callback_args, **callback_kwargs)

2022-05-12T15:14:01-06:00     File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response

2022-05-12T15:14:01-06:00       response = get_response(request)

2022-05-12T15:14:01-06:00     File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner

2022-05-12T15:14:01-06:00   Traceback (most recent call last):

2022-05-12T15:14:01-06:00   2022-05-12 21:14:01,630 ERROR Internal Server Error: /plugins/golden-config/config-compliance/details/92f22ed7-a81c-4ad9-8fd6-81874f1a32b3/sotagg/ - django.request - log - /usr/local/lib/python3.7/site-packages/django/utils/log.py:230

2022-05-12T15:14:01-06:00   KeyError: UUID('92f22ed7-a81c-4ad9-8fd6-81874f1a32b3')

2022-05-12T15:14:01-06:00       settings = get_device_to_settings_map(queryset=Device.objects.filter(pk=device.pk))[device.id]

2022-05-12T15:14:01-06:00     File "/usr/local/lib/python3.7/site-packages/nautobot_golden_config/views.py", line 396, in get

2022-05-12T15:14:01-06:00       return handler(request, *args, **kwargs)

2022-05-12T15:14:01-06:00     File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 98, in dispatch

2022-05-12T15:14:01-06:00       return super().dispatch(request, *args, **kwargs)

2022-05-12T15:14:01-06:00     File "/usr/local/lib/python3.7/site-packages/nautobot/utilities/views.py", line 48, in dispatch

2022-05-12T15:14:01-06:00       return self.dispatch(request, *args, **kwargs)

2022-05-12T15:14:01-06:00     File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 70, in view

2022-05-12T15:14:01-06:00       response = wrapped_callback(request, *callback_args, **callback_kwargs)

2022-05-12T15:14:01-06:00     File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response

2022-05-12T15:14:01-06:00       response = get_response(request)

2022-05-12T15:14:01-06:00     File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner

2022-05-12T15:14:01-06:00   Traceback (most recent call last):

2022-05-12T15:14:01-06:00   2022-05-12 21:14:01,630 ERROR Internal Server Error: /plugins/golden-config/config-compliance/details/92f22ed7-a81c-4ad9-8fd6-81874f1a32b3/sotagg/ - django.request - log - /usr/local/lib/python3.7/site-packages/django/utils/log.py:230

2022-05-12T15:07:49-06:00   [pid: 40|app: 0|req: 18793/122409] 10.23.109.126 () {68 vars in 1339 bytes} [Thu May 12 21:07:49 2022] POST /graphql/ => generated 129 bytes in 5 msecs (HTTP/1.1 400) 8 headers in 381 bytes (1 switches on core 0)
itdependsnetworks commented 2 years ago

Fixed in #262