From 620c3782549d792e62f5d0e6d47742545fda8723 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Fri, 5 Jun 2026 16:52:14 +0200 Subject: [PATCH] fix(notifications): break db <-> notifications.persistence circular import When app.notifications is the import entry point (e.g. Celery loading app.notifications.service before any ORM code), app.db re-entered the half-initialized app.notifications.persistence at its model-registration import and failed with "cannot import name 'Notification' ... partially initialized". Import app.db at the top of app/notifications/__init__.py so db fully initializes (including its own Notification registration) before we re-import from .persistence. Pre-existing issue (reproduces on the base commit); surfaced by the celery worker startup. --- surfsense_backend/app/notifications/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/surfsense_backend/app/notifications/__init__.py b/surfsense_backend/app/notifications/__init__.py index e29c58c0c..6ffe45000 100644 --- a/surfsense_backend/app/notifications/__init__.py +++ b/surfsense_backend/app/notifications/__init__.py @@ -6,6 +6,10 @@ the router in :mod:`app.notifications.api` exposes the inbox endpoints. from __future__ import annotations +# Initialize app.db first to avoid a partial-init circular import when this +# package is the entry point (e.g. Celery loading it before any ORM code). +import app.db # noqa: F401 + from app.notifications.persistence import Notification from app.notifications.service import NotificationService