From 5affbbcaa680ab49395b42801ed51aff4aabdbde Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Wed, 3 Jun 2026 15:52:33 +0200 Subject: [PATCH] fix: initialize document processors in the ingest worker (PR #836 round-5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🟡 The `worker` command never called initialize_document_processors(), so a worker pod with ENABLE_UNSTRUCTURED/TESSERACT/CUSTOM configured silently ran PyMuPDF-only (only the import-time-registered processor). The always-on API pod registers them in its lifespan; the worker has its own startup path, so call initialize_document_processors() there too (before run_worker_async). 🟢 Drop the unused get_database_url monkeypatch in the Postgres integration fixture (build_app_for_url passes the URL explicitly; only the ssl lookup needs pinning). Co-Authored-By: Claude Opus 4.8 (1M context) --- nextcloud_mcp_server/cli.py | 8 ++++++++ tests/integration/test_ingest_queue_postgres.py | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/nextcloud_mcp_server/cli.py b/nextcloud_mcp_server/cli.py index da29f1c7..a5b17257 100644 --- a/nextcloud_mcp_server/cli.py +++ b/nextcloud_mcp_server/cli.py @@ -328,6 +328,14 @@ def worker(concurrency: int | None): workers = concurrency or settings.vector_sync_processor_workers app = get_procrastinate_app() + # Register the configured document processors (Unstructured / Tesseract / + # custom HTTP) in the worker process. The always-on API pod does this in its + # lifespan; the worker has its own startup path, so without this the worker + # would silently fall back to the import-time-registered PyMuPDF only. + from nextcloud_mcp_server.app import initialize_document_processors # noqa: PLC0415 + + initialize_document_processors() + async def _run() -> None: # Open the connector pool once and reuse it for both the defensive # schema apply (the always-on API pod is the authoritative applier) and diff --git a/tests/integration/test_ingest_queue_postgres.py b/tests/integration/test_ingest_queue_postgres.py index 6ac0027c..3ccedcad 100644 --- a/tests/integration/test_ingest_queue_postgres.py +++ b/tests/integration/test_ingest_queue_postgres.py @@ -78,8 +78,8 @@ async def fresh_app(postgres_url: str, monkeypatch: pytest.MonkeyPatch): finally: await engine.dispose() - # get_procrastinate_conninfo derives ssl from settings; point it at the URL. - monkeypatch.setattr(config_module, "get_database_url", lambda: postgres_url) + # build_app_for_url passes the URL explicitly to get_procrastinate_conninfo, + # so only the ssl lookup (which reads settings) needs pinning here. monkeypatch.setattr(config_module, "get_database_ssl", lambda: None) app = build_app_for_url(postgres_url)