From bd4b150457e4a0cb27848bd99d3633d066a5af14 Mon Sep 17 00:00:00 2001 From: Gabriele Pau Date: Fri, 20 Nov 2026 13:36:37 +0100 Subject: [PATCH] fix(editor): record unknown source kinds and keep collecting --- editor-mode/src/editor/ingest.py | 5 +++++ editor-mode/tests/test_pipeline.py | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/editor-mode/src/editor/ingest.py b/editor-mode/src/editor/ingest.py index 72be40c..68bcd75 100644 --- a/editor-mode/src/editor/ingest.py +++ b/editor-mode/src/editor/ingest.py @@ -118,6 +118,11 @@ def collect_archive(db: Database, archive: str, client: httpx.Client, only: set[ r = SourceReport(src.id, src.name) report.sources.append(r) collector = COLLECTORS.get(src.kind) + if collector is None: + r.error = f"unknown source kind: {src.kind}"[:500] + log.warning("source %s failed: %s", src.name, r.error) + failed.append((src.id, r.error, True)) + continue spec = SourceSpec(src.kind, src.url, src.config or {}, src.etag, src.last_modified) try: result = collector.fetch(client, spec) diff --git a/editor-mode/tests/test_pipeline.py b/editor-mode/tests/test_pipeline.py index 9a41b6c..99e0f4a 100644 --- a/editor-mode/tests/test_pipeline.py +++ b/editor-mode/tests/test_pipeline.py @@ -9,7 +9,7 @@ from sqlalchemy import text from conftest import fixture -from editor import repo +from editor import ingest, repo from editor.core_client import CoreClient from editor.core_fetch import core_http_client from editor.ingest import collect_tenant @@ -78,6 +78,18 @@ def test_failing_source_is_recorded_and_others_continue(db, tenant): assert errors == 2 +@respx.mock +def test_an_unknown_source_kind_does_not_stop_the_other_sources(db, tenant, monkeypatch): + add_sources(db, tenant) + monkeypatch.setattr(ingest, "COLLECTORS", {k: v for k, v in ingest.COLLECTORS.items() if k != "hackernews"}) + respx.get(FEED).mock(return_value=httpx.Response(200, content=fixture("rss.xml"))) + respx.get(FEED2).mock(return_value=httpx.Response(200, content=MIRROR)) + with httpx.Client() as c: + report = collect_tenant(db, tenant, c) + assert [r.error for r in report.sources][2] == "unknown source kind: hackernews" + assert report.new > 0 + + @respx.mock def test_the_cores_trouble_is_not_the_sources_fault(db, tenant): """Out of daily fetches or the Core down: the sources stay active and