extras/plugins: fix typo in dict key #4459

Closed
opened 2025-12-29 18:36:12 +01:00 by adam · 3 comments
Owner

Originally created by @pvinci on GitHub (Jan 12, 2021).

Environment

  • Python version: 3.8
  • NetBox version: 2.10.3

Steps to Reproduce

cd <home>/netbox/netbox
DJANGO_SETTINGS_MODULE=<home>/netbox/netbox/netbox/configuration.testing.py
../venv/bin/python3
Python 3.8.2 (default, Nov  4 2020, 21:23:28)
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

from django.conf import settings
settings.configure()
from extras.plugins import views
from extras import plugins

plugin_app_config = plugins.PluginConfig
# let's set a value or we're going to get back an empty string
plugin_app_config.version = "1.2.3"

# raises AttributeError if missing
plugin_app_config.verbose_name = "Verbose Name"
plugin_app_config.name = "name"

version = views.InstalledPluginsAPIView._get_plugin_data(plugin_app_config)['version']
print(version)

Expected Behavior

version = views.InstalledPluginsAPIView._get_plugin_data(plugin_app_config)['version']
print(version)
1.2.3

Observed Behavior

version = views.InstalledPluginsAPIView._get_plugin_data(plugin_app_config)['version']
Traceback (most recent call last):
File "", line 1, in
KeyError: 'version'

Originally created by @pvinci on GitHub (Jan 12, 2021). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reporting reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, please start a discussion instead: https://github.com/netbox-community/netbox/discussions Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: 3.8 * NetBox version: 2.10.3 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce ``` cd <home>/netbox/netbox DJANGO_SETTINGS_MODULE=<home>/netbox/netbox/netbox/configuration.testing.py ../venv/bin/python3 Python 3.8.2 (default, Nov 4 2020, 21:23:28) [Clang 12.0.0 (clang-1200.0.32.28)] on darwin Type "help", "copyright", "credits" or "license" for more information. from django.conf import settings settings.configure() from extras.plugins import views from extras import plugins plugin_app_config = plugins.PluginConfig # let's set a value or we're going to get back an empty string plugin_app_config.version = "1.2.3" # raises AttributeError if missing plugin_app_config.verbose_name = "Verbose Name" plugin_app_config.name = "name" version = views.InstalledPluginsAPIView._get_plugin_data(plugin_app_config)['version'] print(version) ``` <!-- What did you expect to happen? --> ### Expected Behavior >>> version = views.InstalledPluginsAPIView._get_plugin_data(plugin_app_config)['version'] >>> print(version) 1.2.3 <!-- What happened instead? --> ### Observed Behavior >>> version = views.InstalledPluginsAPIView._get_plugin_data(plugin_app_config)['version'] Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: 'version'
adam closed this issue 2025-12-29 18:36:12 +01:00
Author
Owner

@DanSheps commented on GitHub (Jan 13, 2021):

This issue is pending closure as it does not conform to one of the provided templates as required by the contributing guide. If you'd like to request that your issue be re-opened, please first update the content so that it matches the appropriate template (this may require rewriting your issue entirely).

@DanSheps commented on GitHub (Jan 13, 2021): This issue is pending closure as it does not conform to one of the [provided templates](https://github.com/netbox-community/netbox/issues/new/choose) as required by the [contributing guide](https://github.com/netbox-community/netbox/blob/master/CONTRIBUTING.md). If you'd like to request that your issue be re-opened, please first update the content so that it matches the appropriate template (this may require rewriting your issue entirely).
Author
Owner

@pvinci commented on GitHub (Jan 13, 2021):

@DanSheps
How would you suggest conforming this? A typo in a dict key is not strongly typed.
Would adding something like this be sufficient?
$ grep -r verison .
./netbox/extras/plugins/views.py: 'verison': plugin_app_config.version

@pvinci commented on GitHub (Jan 13, 2021): @DanSheps How would you suggest conforming this? A typo in a dict key is not strongly typed. Would adding something like this be sufficient? $ grep -r verison . ./netbox/extras/plugins/views.py: 'verison': plugin_app_config.version
Author
Owner

@DanSheps commented on GitHub (Jan 13, 2021):

You didn't explain what the problem is, please go ahead and explain the problem before we consider opening this and follow the contributing guidelines.

We have no idea what you are asking for here. What is the exact problem? How do you cause this problem? What is the result? What should happen.

@DanSheps commented on GitHub (Jan 13, 2021): You didn't explain what the problem is, please go ahead and explain the problem before we consider opening this and follow the contributing guidelines. We have no idea what you are asking for here. What is the exact problem? How do you cause this problem? What is the result? What should happen.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4459