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

* Check for null plugin config

* Handle potential errors

(cherry picked from commit 2e675ee87a)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot] 2026-02-22 12:56:57 +11:00 committed by GitHub
parent ed8331e26a
commit 44387f3bb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 5 deletions

View File

@ -473,12 +473,19 @@ class PluginsRegistry:
# Ensure that each loaded plugin has a valid configuration object in the database
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
if config.is_mandatory() and not config.active:
config.active = True
config.save(no_reload=True)
try:
config.save(no_reload=True)
except (OperationalError, ProgrammingError):
# 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:
logger.exception('Unexpected error during plugin reload: %s', e)