nautobot-app-golden-config
nautobot-app-golden-config copied to clipboard
KeyError when trying to configure columns for Config Compliance table view
Environment
- Python version: 3.11.10
- Nautobot version: 2.3.6
- nautobot-golden-config version: 2.1.2
Expected Behavior
I expected to be able to set the columns in the table view on the Config Compliance page
Observed Behavior
<class 'KeyError'>
'dynamic_group_count'
Steps to Reproduce
- Go to Config Compliance table view
- Click the Configure button to edit the columns
- Make any (or no changes) and hit Save
Issue originally reported via slack: https://networktocode.slack.com/archives/C01NWPK6WHL/p1727879954240279
Workaround
Since this issue can cause the Config Compliance view to be rendered inoperable, you can use the following steps to remediate the issue temporarily:
- Click on your username in the side navigation bar and go to Profile
- Go to Preferences
- Select
tables.ConfigComplianceTable.columnsand click Clear Selected
@glennmatthews Does it seem reasonable to just turn dynamic groups off this model for now? e.g. is_dynamic_group_associable_model = False on the model.
If you don't see a use case for dynamic groups of ConfigCompliance, absolutely that would be the appropriate fix. See also the note added in v2.3.6 release notes (we missed it in v2.3.0, sorry!):
App Developers should review the feature set of their data models and consider whether their models should opt into or out of inclusion in Dynamic Groups, Contacts/Teams, Object Metadata, and Saved Views via the inclusion or omission of appropriate model mixins and flag variables. Refer to the developer documentation for details.
~I think the fix here is just changing the order of operations in tables.py here~
Don't do the above. We shouldn't be touching Table.base_columns after calling BaseTable.__init__. See the below traceback from recreating the bug:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 220, in _get_response
response = response.render()
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/template/response.py", line 114, in render
self.content = self.rendered_content
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/rest_framework/response.py", line 74, in rendered_content
ret = renderer.render(self.data, accepted_media_type, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/nautobot/core/views/renderers.py", line 370, in render
return super().render(data, accepted_media_type=accepted_media_type, renderer_context=renderer_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/rest_framework/renderers.py", line 727, in render
context = self.get_context(data, accepted_media_type, renderer_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/nautobot/core/views/renderers.py", line 236, in get_context
table = self.construct_table(view, request=request, permissions=permissions)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/nautobot/core/views/renderers.py", line 97, in construct_table
table = table_class(
File "/source/nautobot_golden_config/tables.py", line 180, in __init__
super().__init__(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/nautobot/core/tables.py", line 153, in __init__
self.columns.hide(name)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django_tables2/columns/base.py", line 797, in hide
self.columns[name].column.visible = False
^^^^^^^^^^^^^^^^^^
Exception Type: KeyError at /plugins/golden-config/config-compliance/
Exception Value: 'dynamic_group_count'