Log mailbox refresh failures safely

This commit is contained in:
2026-07-21 03:16:23 +02:00
parent 658c1e6d5d
commit b2c013174a
2 changed files with 9 additions and 4 deletions

View File

@@ -1,7 +1,5 @@
from __future__ import annotations from __future__ import annotations
from typing import Any
from govoplan_core.core.modules import ModuleContext from govoplan_core.core.modules import ModuleContext
from govoplan_mail.backend.runtime import configure_runtime from govoplan_mail.backend.runtime import configure_runtime
from govoplan_mail.backend.mail_profiles import ( from govoplan_mail.backend.mail_profiles import (

View File

@@ -1,6 +1,7 @@
from __future__ import annotations from __future__ import annotations
import dataclasses import dataclasses
import logging
from types import SimpleNamespace from types import SimpleNamespace
from typing import Any from typing import Any
@@ -69,6 +70,7 @@ from govoplan_mail.backend.sending.imap import ImapAppendError, ImapConfiguratio
from govoplan_mail.backend.sending.smtp import test_smtp_login from govoplan_mail.backend.sending.smtp import test_smtp_login
router = APIRouter(prefix="/mail", tags=["mail"]) router = APIRouter(prefix="/mail", tags=["mail"])
logger = logging.getLogger(__name__)
MAIL_MODULE_ID = "mail" MAIL_MODULE_ID = "mail"
MAIL_PROFILES_COLLECTION = "mail.profiles" MAIL_PROFILES_COLLECTION = "mail.profiles"
@@ -497,7 +499,12 @@ def _refresh_mailbox_index_task(
except Exception: except Exception:
# Background refresh is opportunistic. Foreground requests will surface # Background refresh is opportunistic. Foreground requests will surface
# concrete IMAP errors when no usable cache is available. # concrete IMAP errors when no usable cache is available.
pass logger.debug(
"Background mailbox index refresh failed (profile_id=%r, folder=%r)",
profile_id,
folder,
exc_info=True,
)
finally: finally:
finish_mailbox_refresh(tenant_id, profile_id, folder) finish_mailbox_refresh(tenant_id, profile_id, folder)
@@ -826,7 +833,7 @@ def write_mail_profile_policy(
scope_type = scope_type.strip().casefold() scope_type = scope_type.strip().casefold()
_require_policy_write_scope(principal, scope_type) _require_policy_write_scope(principal, scope_type)
try: try:
policy = set_mail_profile_policy( set_mail_profile_policy(
session, session,
tenant_id=principal.tenant_id, tenant_id=principal.tenant_id,
scope_type=scope_type, scope_type=scope_type,