2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-02-25 16:17:58 +00:00

[bug] Check for null plugin config (#11394)

* Check for null plugin config

* Handle potential errors
This commit is contained in:
Oliver
2026-02-22 12:47:43 +11:00
committed by GitHub
parent 782c765685
commit 2e675ee87a

View File

@@ -473,12 +473,19 @@ class PluginsRegistry:
# Ensure that each loaded plugin has a valid configuration object in the database # Ensure that each loaded plugin has a valid configuration object in the database
for plugin in self.plugins.values(): for plugin in self.plugins.values():
config = self.get_plugin_config(plugin.slug) if config := self.get_plugin_config(plugin.slug):
# Ensure mandatory plugins are marked as active
if config.is_mandatory() and not config.active:
config.active = True
# Ensure mandatory plugins are marked as active try:
if config.is_mandatory() and not config.active: config.save(no_reload=True)
config.active = True except (OperationalError, ProgrammingError):
config.save(no_reload=True) # Database is not ready, cannot save config
logger.warning(
"Database not ready - cannot set mandatory flag for plugin '%s'",
plugin.slug,
)
except Exception as e: except Exception as e:
logger.exception('Unexpected error during plugin reload: %s', e) logger.exception('Unexpected error during plugin reload: %s', e)