~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(download): log auto-indexing failures by exception type only (#7243)
LearningCircuit88185e0148bc
diff --git a/src/local_deep_research/research_library/services/download_service.py b/src/local_deep_research/research_library/services/download_service.pyindex 4294841d18..7f98ef8257 100644--- a/src/local_deep_research/research_library/services/download_service.py+++ b/src/local_deep_research/research_library/services/download_service.py@@ -51,6 +51,7 @@ from ...security.client_safe_errors import (CLIENT_SAFE_DOWNLOAD_MESSAGES,client_safe_download_message,)+from ...security.secure_logging import log_exception_typefrom ...database.models.library import (Collection,Document as Document,@@ -899,7 +900,7 @@ class DownloadService:self.username,self.password,)- except Exception:+ except Exception as exc:# The Document SELECT above runs on the shared session; a# connection-level failure there leaves it needing a# rollback. Auto-indexing is best-effort so we swallow and@@ -911,7 +912,7 @@ class DownloadService:# get_user_db_session block, and trigger_auto_index does its# DB work off-thread, so neither dirties this session.)safe_rollback(session, "download_resource auto-index")- logger.exception("Failed to trigger auto-indexing")+ log_exception_type("Failed to trigger auto-indexing", exc)finally:# Release any checked-out connection from the auto-index querysession.commit()diff --git a/src/local_deep_research/security/secure_logging.py b/src/local_deep_research/security/secure_logging.pyindex 935462728d..5b2c37d772 100644--- a/src/local_deep_research/security/secure_logging.py+++ b/src/local_deep_research/security/secure_logging.py@@ -1,4 +1,7 @@-"""Loguru wrapper whose ``.exception()`` gates tracebacks behind diagnose mode.+"""Shared logging helpers for controlling exception detail.++``log_exception_type()`` logs a fixed action and exception class at ERROR+without exception text or tracebacks, including in diagnose mode.Provider and search-engine exception handlers must stay observable atERROR level, but plain ``loguru.logger.exception()`` always attaches the@@ -50,6 +53,21 @@ import osfrom loguru import logger as _loguru_logger+def log_exception_type(action: str, exc: Exception) -> None:+ """Log a fixed action and exception class without exception details.++ ``action`` must be developer-written text, with no request data or+ exception text interpolated into it. The exception is never stringified+ or attached to the record, even in diagnose mode. ``depth=1`` preserves+ the caller's location and module-based logging filters.+ """+ _loguru_logger.opt(exception=False, depth=1).error(+ "{action} ({error_type})",+ action=action,+ error_type=type(exc).__name__,+ )++def env_truthy(name: str) -> bool:"""Return True if env var *name* is set to a truthy value ("1", "true", "yes")."""return os.environ.get(name, "").strip().lower() in ("1", "true", "yes")diff --git a/tests/security/test_secure_logging.py b/tests/security/test_secure_logging.pyindex f396769151..79a9566ca2 100644--- a/tests/security/test_secure_logging.py+++ b/tests/security/test_secure_logging.py@@ -1,4 +1,4 @@-"""Tests for the diagnose-gated ``SecureLogger`` wrapper.+"""Tests for shared exception logging and the ``SecureLogger`` wrapper.``security.secure_logging.logger.exception()`` must log at ERROR levelwhile attaching the active exception to the record ONLY when both@@ -14,6 +14,7 @@ from local_deep_research.security.secure_logging import (SecureLogger,env_truthy,is_diagnose_mode,+ log_exception_type,logger,)@@ -46,6 +47,66 @@ def _log_wrapped_exception(message="request failed: scrubbed"):logger.exception(message)+class TestLogExceptionType:+ @pytest.mark.parametrize("diagnose", [None, "1"])+ def test_omits_exception_details_even_in_diagnose_mode(+ self, monkeypatch, loguru_caplog_full, diagnose+ ):+ _set_env(monkeypatch, diagnose, diagnose)++ class UnprintableError(Exception):+ def __str__(self):+ raise AssertionError("exception text must not be read")++ with loguru_caplog_full.at_level("ERROR"):+ try:+ try:+ raise ValueError("https://user:[email protected]/private")+ except ValueError as cause:+ raise UnprintableError(+ "private exception details"+ ) from cause+ except UnprintableError as exc:+ log_exception_type("Failed to trigger auto-indexing", exc)++ records = [+ record+ for record in loguru_caplog_full.records+ if "Failed to trigger auto-indexing" in record.getMessage()+ ]+ assert len(records) == 1+ assert records[0].getMessage().rstrip("\n") == (+ "Failed to trigger auto-indexing (UnprintableError)"+ )+ assert records[0].levelname == "ERROR"+ assert records[0].exc_info is None+ assert "Traceback" not in loguru_caplog_full.text+ assert "secret" not in loguru_caplog_full.text+ assert "private exception details" not in loguru_caplog_full.text++ def test_preserves_caller_attribution_and_namespace_filter(self):+ captured = []+ handler_id = logger.add(+ lambda message: captured.append(message.record),+ level="ERROR",+ )+ try:+ log_exception_type("type-only attribution", RuntimeError("private"))+ record = captured[-1]+ assert record["name"] == __name__+ assert record["function"] == (+ "test_preserves_caller_attribution_and_namespace_filter"+ )+ assert record["exception"] is None++ logger.disable(__name__)+ log_exception_type("disabled caller", RuntimeError("private"))+ assert len(captured) == 1+ finally:+ logger.enable(__name__)+ logger.remove(handler_id)++class TestEnvTruthy:@pytest.mark.parametrize("value", ["1", "true", "TRUE", "yes", " YES "])def test_truthy_values(self, monkeypatch, value):