Refactor configuration handling and improve error management across services; normalize placeholder values for SMTP and Stripe configurations; enhance local storage fallback logic in StorageService; add tests for new behaviors and edge cases.

This commit is contained in:
Your Name
2026-03-26 14:15:10 +02:00
parent 688d411537
commit bc8a5dc290
19 changed files with 423 additions and 95 deletions

View File

@@ -0,0 +1,31 @@
"""Helpers for treating sample config values as missing runtime configuration."""
import re
_MASKED_SEQUENCE_RE = re.compile(r"(x{6,}|\*{4,})", re.IGNORECASE)
def normalize_optional_config(
value: str | None,
placeholder_markers: tuple[str, ...] = (),
) -> str:
"""Return a stripped config value, or blank when it still looks like a sample."""
normalized = str(value or "").strip()
if not normalized:
return ""
lowered = normalized.lower()
if any(marker.lower() in lowered for marker in placeholder_markers if marker):
return ""
if _MASKED_SEQUENCE_RE.search(normalized):
return ""
return normalized
def has_real_config(
value: str | None,
placeholder_markers: tuple[str, ...] = (),
) -> bool:
"""Return True when the value is present and not an obvious placeholder."""
return bool(normalize_optional_config(value, placeholder_markers))