Typo in PluginConfig _load_resource method #7733

Closed
opened 2025-12-29 20:27:37 +01:00 by adam · 2 comments
Owner

Originally created by @JulianJacobi on GitHub (Mar 8, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.4.5

Python version

3.11

Steps to Reproduce

  1. Create a plugin, that uses some resource loading (i.e. template_extensions) and explicitly define this resource path in PluginConfig class with template_extensions = 'template_extensions'
  2. Install Plugin
  3. Start Netbox

Expected Behavior

Netbox should start normally, with plugin loaded.

Observed Behavior

An ImportError exception is raised saying that the plugin has not defined an attribute/class called exactly like the name of the plugin.

Originally created by @JulianJacobi on GitHub (Mar 8, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.4.5 ### Python version 3.11 ### Steps to Reproduce 1. Create a plugin, that uses some resource loading (i.e. `template_extensions`) and explicitly define this resource path in `PluginConfig` class with `template_extensions = 'template_extensions'` 2. Install Plugin 3. Start Netbox ### Expected Behavior Netbox should start normally, with plugin loaded. ### Observed Behavior An ImportError exception is raised saying that the plugin has not defined an attribute/class called exactly like the name of the plugin.
adam added the type: bugstatus: accepted labels 2025-12-29 20:27:37 +01:00
adam closed this issue 2025-12-29 20:27:38 +01:00
Author
Owner

@JulianJacobi commented on GitHub (Mar 8, 2023):

It seems that the problem is related to fbc9fea0.

IMHO this line

return import_string(f"{self.__module__}.{self.name}") should be return import_string(f"{self.__module__}.{getattr(self, name)}")

@JulianJacobi commented on GitHub (Mar 8, 2023): It seems that the problem is related to fbc9fea0. IMHO [this line](https://github.com/netbox-community/netbox/blob/33286aad391de51a460189649c5187ddbd8ed4ce/netbox/extras/plugins/__init__.py#L82) `return import_string(f"{self.__module__}.{self.name}")` should be `return import_string(f"{self.__module__}.{getattr(self, name)}")`
Author
Owner

@abhi1693 commented on GitHub (Mar 8, 2023):

That's a really good find. I too see this exact issue and your fix does seem to be loading it correctly.

@abhi1693 commented on GitHub (Mar 8, 2023): That's a really good find. I too see this exact issue and your fix does seem to be loading it correctly.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7733