Add system-check for EVENT_STORAGES setting

This commit is contained in:
Klaas van Schelven
2025-02-18 12:08:05 +01:00
parent 10f8e10607
commit 3cb07246b9

View File

@@ -2,6 +2,7 @@ from django.core.checks import Warning, register
from django.conf import settings
from bugsink.app_settings import get_settings
from events.storage_registry import get_write_storage
@register("bsmain")
@@ -14,3 +15,18 @@ def check_no_nested_settings_in_unnested_form(app_configs, **kwargs):
f"'BUGSINK' setting."
))
return errors
@register("bsmain")
def check_event_storage_properly_configured(app_configs, **kwargs):
errors = []
try:
# rather than doing an explicit check, we just run the `get_write_storage` code and see if it throws an error
# get_write_storage() touches the whole storage system, so if it fails, we know something is wrong
get_write_storage()
except ValueError as e:
errors.append(Warning(
str(e),
id="bsmain.W002",
))
return errors